/// <summary> /// /// </summary> /// <param name="targetHost"></param> /// <param name="clientCertificates"></param> /// <param name="caCertificates"></param> /// <param name="enabledSslProtocols"></param> /// <param name="sslStrength"></param> /// <param name="checkCertificateRevocation"></param> /// <param name="asyncCallback"></param> /// <param name="asyncState"></param> /// <returns></returns> public virtual IAsyncResult BeginAuthenticateAsClient( string targetHost, X509List clientCertificates, X509Chain caCertificates, SslProtocols enabledSslProtocols, SslStrength sslStrength, bool checkCertificateRevocation, AsyncCallback asyncCallback, Object asyncState) { if (IsAuthenticated) { throw new InvalidOperationException("SslStream is already authenticated"); } End = ConnectionEnd.Client; // Create the stream var client_stream = new SslStreamClient( InnerStream, targetHost, clientCertificates, caCertificates, enabledSslProtocols, sslStrength, checkCertificateRevocation, remoteCertificateValidationCallback, localCertificateSelectionCallback); // set the internal stream sslStream = client_stream; // start the write operation return(BeginWrite(new byte[0], 0, 0, asyncCallback, asyncState)); }
/// <summary> /// /// </summary> /// <param name="targetHost"></param> /// <param name="clientCertificates"></param> /// <param name="caCertificates"></param> /// <param name="enabledSslProtocols"></param> /// <param name="sslStrength"></param> /// <param name="checkCertificateRevocation"></param> /// <param name="asyncCallback"></param> /// <param name="asyncState"></param> /// <returns></returns> public virtual IAsyncResult BeginAuthenticateAsClient( string targetHost, X509List clientCertificates, X509Chain caCertificates, SslProtocols enabledSslProtocols, SslStrength sslStrength, bool checkCertificateRevocation, AsyncCallback asyncCallback, Object asyncState) { if (IsAuthenticated) { throw new InvalidOperationException("SslStream is already authenticated"); } End = ConnectionEnd.Client; // Create the stream var client_stream = new SslStreamClient( InnerStream, targetHost, clientCertificates, caCertificates, enabledSslProtocols, sslStrength, checkCertificateRevocation, remoteCertificateValidationCallback, localCertificateSelectionCallback); // set the internal stream sslStream = client_stream; // start the write operation return BeginWrite(new byte[0], 0, 0, asyncCallback, asyncState); }