예제 #1
0
        public void AuthenticateAsClient(string host)
        {
            if (tlsStreams != null)
            {
                throw new InvalidOperationException("TLS has already been activated on this Socket.");
            }
            try {
                Socket.Blocking = true;

                tlsStreams = new SocketTlsStreams(Socket);
                tlsStreams.SslStream.AuthenticateAsClient(host);

                SendQueue();
            }
            catch (Exception ex) {
                OnException(ex);
            }
        }
예제 #2
0
        public void AuthenticateAsServer(X509Certificate certificate)
        {
            if (certificate == null)
            {
                throw new ArgumentNullException("certificate");
            }
            if (tlsStreams != null)
            {
                throw new InvalidOperationException("TLS has already been activated on this Socket.");
            }
            try {
                Socket.Blocking = true;

                tlsStreams = new SocketTlsStreams(Socket);
                tlsStreams.SslStream.AuthenticateAsServer(certificate);

                SendQueue();
            }
            catch (Exception ex) {
                OnException(ex);
            }
        }