Ejemplo n.º 1
0
        public SslListener(SocketListener baseListener, X509Certificate serverCertificate, ISslAuthenticationListener listener)
        {
            //The listener is used to accept a socket capable of basic data transport, e.g. UDT.
            this.baseListener = baseListener;

            //The certificate is used in the AuthenticateAsServer SSL method.
            this.serverCertificate = serverCertificate;

            //Set the listener.
            this.authenticationListener = listener;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates a new SSL socket, based on a lower-level transport socket.
        /// SSL does not implement reliability, and only provides layer security. Using
        /// UDT or TCP is required at this layer.
        /// </summary>
        /// <param name="baseSocket">Base socket to reference.</param>
        /// <param name="authenticationListener">SSL authentication listener responsible for checking remote certificates.</param>
        public SslSocket(Socket baseSocket, ISslAuthenticationListener authenticationListener)
        {
            this.baseSocket = baseSocket;
            this.listener   = authenticationListener;

            if (baseSocket.IsConnected())
            {
                this.sslStream = new SslStream(
                    baseSocket.GetStream(),
                    false,
                    new RemoteCertificateValidationHandler(ValidationCallback),
                    new LocalCertificateSelectionHandler(SelectionCallback)
                    );
            }
        }