public override void Connect() { this.socket = new StreamSocket(); // connection is executed synchronously this.socket.ConnectAsync(this.remoteHostName, this.remotePort.ToString(), SslHelper.ToSslPlatformEnum(this.sslProtocol)).AsTask().Wait(); }
/// <summary> /// Connect to remote server /// </summary> public override void Connect() { base.Connect(); // create SSL stream this.sslStream = new SslStream(this.socket); // server authentication (SSL/TLS handshake) this.sslStream.AuthenticateAsClient(this.remoteHostName, this.clientCert, new X509Certificate[] { this.caCert }, SslVerification.CertificateRequired, SslHelper.ToSslPlatformEnum(this.sslProtocol)); }
/// <summary> /// Connect to remote server /// </summary> public override void Connect() { base.Connect(); // create SSL stream this.netStream = new NetworkStream(this.socket); this.sslStream = new SslStream(this.netStream, false, this.userCertificateValidationCallback, this.userCertificateSelectionCallback); // server authentication (SSL/TLS handshake) X509CertificateCollection clientCertificates = null; // check if there is a client certificate to add to the collection, otherwise it's null (as empty) if (this.clientCert != null) { clientCertificates = new X509CertificateCollection(new X509Certificate[] { this.clientCert }); } this.sslStream.AuthenticateAsClient(this.remoteHostName, clientCertificates, SslHelper.ToSslPlatformEnum(this.sslProtocol), false); }
/// <summary> /// Accept connection from a remote client /// </summary> public override void Accept() { this.netStream = new NetworkStream(this.socket); this.sslStream = new SslStream(this.netStream, false, this.userCertificateValidationCallback, this.userCertificateSelectionCallback); this.sslStream.AuthenticateAsServer(this.serverCert, false, SslHelper.ToSslPlatformEnum(this.sslProtocol), false); }