Пример #1
0
        internal static WsStream CreateClientStream(TcpClient client, bool secure, string host, RemoteCertificateValidationCallback validationCallback)
        {
            NetworkStream stream = client.GetStream();

            if (secure)
            {
                if (validationCallback == null)
                {
                    validationCallback = ((object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) => true);
                }
                WebSocketSharp.Net.Security.SslStream sslStream = new WebSocketSharp.Net.Security.SslStream(stream, false, validationCallback);
                sslStream.AuthenticateAsClient(host);
                return(new WsStream(sslStream));
            }
            return(new WsStream(stream));
        }
Пример #2
0
        internal static WsStream CreateClientStream(string hostname, int port, out TcpClient client)
        {
            client = new TcpClient(hostname, port);
              var netStream = client.GetStream();

              if (port == 443)
              {
            System.Net.Security.RemoteCertificateValidationCallback validationCb = (sender, certificate, chain, sslPolicyErrors) =>
            {
              // FIXME: Always returns true
              return true;
            };

            var sslStream = new SslStream(netStream, false, validationCb);
            sslStream.AuthenticateAsClient(hostname);

            return new WsStream(sslStream);
              }

              return new WsStream(netStream);
        }
        internal static WsStream CreateClientStream(
      TcpClient client,
      bool secure,
      string host,
      System.Net.Security.RemoteCertificateValidationCallback validationCallback
    )
        {
            var netStream = client.GetStream ();
              if (secure)
              {
            if (validationCallback == null)
              validationCallback = (sender, certificate, chain, sslPolicyErrors) => true;

            var sslStream = new SslStream (netStream, false, validationCallback);
            sslStream.AuthenticateAsClient (host);

            return new WsStream (sslStream);
              }

              return new WsStream (netStream);
        }
Пример #4
0
        internal static WsStream CreateClientStream(TcpClient tcpClient, string host, bool secure)
        {
            var netStream = tcpClient.GetStream();
              if (secure)
              {
            System.Net.Security.RemoteCertificateValidationCallback callback = (sender, certificate, chain, sslPolicyErrors) =>
            {
              // FIXME: Always returns true
              return true;
            };

            var sslStream = new SslStream(netStream, false, callback);
            sslStream.AuthenticateAsClient(host);

            return new WsStream(sslStream);
              }

              return new WsStream(netStream);
        }