Inheritance: Stream, IDisposable
Example #1
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="serverCertificate"></param>
        /// <param name="clientCertificateRequired"></param>
        /// <param name="caCerts"></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 BeginAuthenticateAsServer(
			X509Certificate serverCertificate,
			bool clientCertificateRequired,
			X509Chain caCerts,
			SslProtocols enabledSslProtocols,
			SslStrength sslStrength,
			bool checkCertificateRevocation,
			AsyncCallback asyncCallback,
			Object asyncState)
        {
            if (IsAuthenticated)
            {
                throw new InvalidOperationException("SslStream is already authenticated");
            }

            End = ConnectionEnd.Server;

            // Initialize the server stream
            var server_stream = new SslStreamServer(InnerStream, false, serverCertificate, clientCertificateRequired, caCerts, enabledSslProtocols, sslStrength, checkCertificateRevocation, remoteCertificateValidationCallback);
            // Set the internal sslStream
            sslStream = server_stream;
            // Start the read operation
            return BeginRead(new byte[0], 0, 0, asyncCallback, asyncState);
        }
Example #2
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="dh"></param>
        /// <param name="enabledSslProtocols"></param>
        /// <param name="sslStrength"></param>
        /// <param name="asyncCallback"></param>
        /// <param name="asyncState"></param>
        /// <returns></returns>
        public virtual IAsyncResult BeginAuthenticateAsServer(
            DH dh,
			SslProtocols enabledSslProtocols,
			SslStrength sslStrength,
			AsyncCallback asyncCallback,
			Object asyncState)
        {
            if (IsAuthenticated)
            {
                throw new InvalidOperationException("SslStream is already authenticated");
            }
            // Initialize the server stream
            SslAnonStreamServer server_stream = new SslAnonStreamServer(InnerStream, false, dh, enabledSslProtocols, sslStrength);
            // Set the internal sslStream
            sslStream = server_stream;
            // Start the read operation
            return BeginRead(new byte[0], 0, 0, asyncCallback, asyncState);
        }
Example #3
0
        /// <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, false, 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);
        }