Exemplo n.º 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);
            }
        }
Exemplo n.º 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);
            }
        }