public void Connect()
        {
            this.socket = new StreamSocket();

            // connection is executed synchronously
            this.socket.ConnectAsync(this.remoteHostName,
                                     this.remotePort.ToString(),
                                     MqttSslUtility.ToSslPlatformEnum(this.sslProtocol)).AsTask().Wait();
        }
Exemplo n.º 2
0
 public void Accept()
 {
     if (!this.secure)
     {
         return;
     }
     this.netStream = new NetworkStream(this.socket);
     this.sslStream = new SslStream((Stream)this.netStream, false, this.userCertificateValidationCallback, this.userCertificateSelectionCallback);
     this.sslStream.AuthenticateAsServer(this.serverCert, false, MqttSslUtility.ToSslPlatformEnum(this.sslProtocol), false);
 }
Exemplo n.º 3
0
        public void Connect()
        {
            this.socket = new Socket(this.remoteIpAddress.GetAddressFamily(), SocketType.Stream, ProtocolType.Tcp);
            this.socket.Connect((EndPoint) new IPEndPoint(this.remoteIpAddress, this.remotePort));
            if (!this.secure)
            {
                return;
            }
            this.netStream = new NetworkStream(this.socket);
            this.sslStream = new SslStream((Stream)this.netStream, false, this.userCertificateValidationCallback, this.userCertificateSelectionCallback);
            X509CertificateCollection clientCertificates = (X509CertificateCollection)null;

            if (this.clientCert != null)
            {
                clientCertificates = new X509CertificateCollection(new X509Certificate[1]
                {
                    this.clientCert
                });
            }
            this.sslStream.AuthenticateAsClient(this.remoteHostName, clientCertificates, MqttSslUtility.ToSslPlatformEnum(this.sslProtocol), false);
        }