none
Using of non secure websocket (i.e ws://) from secured origin site (i.e https://xx.yy.com) RRS feed

  • Question

  • Hi,

    We are having an web application (hosted in secured channel i.e. https).  From one of the page from this web site, we need to invoke a COM component without using ActiveX Control object.  we are planning to build a web socket application which listens to a particular port in the end customers system and based on the request will create an instance of the COM component and invoke appropriate method of the COM Component.  we are planning to deploy the websocket server application in the end customer systems.

    We are using Javascript as client side code to make a connection to the websocket server.  We can not use the secured web socket connection i.e. wss since we can not deploy any certificates with private key in the end point systems. hence we are using non secured approach .i.e ws.

    Connection to websocket code is as below

    try{
      connection = new WebSocket('ws://localhost:642');
      } catch(err)  {
        console.log(err.message);
      }

    Our C# code to make connection is 

    TcpListener listener = new TcpListener(ipAddress, port);
          Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
          listener.Start();
          Console.WriteLine("Websocket Server:  Listening on {0}.{1}Waiting for browser socket to connect...", listener.LocalEndpoint, Environment.NewLine);
          Listenclient(listener);
    }      


          private static void Listenclient(TcpListener listener) {
          while (true) {
            listener.BeginAcceptSocket(new AsyncCallback(OnAcceptConnection), listener);

          }
        }

        private  async static void OnAcceptConnection(IAsyncResult result) {
          try {

            TcpListener server = ((TcpListener)result.AsyncState);
            Socket sock = server.EndAcceptSocket(result);
            var client = new ClientSession(sock);
            ClientSession cs = new ClientSession()
            cs.RegisterClient(client);
            Console.WriteLine("\r\nWebsocket Server: Established connection with browser socket {0}....", sock.RemoteEndPoint);
          } catch (SocketException e) {
            Console.WriteLine("\r\nWebsocket Server: Socket Error Occured(Start Accept New):" + e.Message);
          }
        }

    However I am getting the Security Error when it is trying to open the websocket connection as my site is running on https;// mode.  Is there any alternative is there for this.  

    Thanking in advance

    Sheshagiri

    • Moved by CoolDadTx Thursday, July 26, 2018 1:50 PM ASP.NET related
    Thursday, July 26, 2018 5:46 AM

All replies