Ejemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TTLSServerSocket" /> class.
        /// </summary>
        /// <param name="port">The port where the server runs.</param>
        /// <param name="clientTimeout">Send/receive timeout.</param>
        /// <param name="useBufferedSockets">If set to <c>true</c> [use buffered sockets].</param>
        /// <param name="certificate">The certificate object.</param>
        /// <param name="clientCertValidator">The certificate validator.</param>
        /// <param name="localCertificateSelectionCallback">The callback to select which certificate to use.</param>
        public TTLSServerSocket(
            int port,
            int clientTimeout,
            bool useBufferedSockets,
            X509Certificate2 certificate,
            RemoteCertificateValidationCallback clientCertValidator             = null,
            LocalCertificateSelectionCallback localCertificateSelectionCallback = null)
        {
            if (!certificate.HasPrivateKey)
            {
                throw new TTransportException(TTransportException.ExceptionType.Unknown, "Your server-certificate needs to have a private key");
            }

            this.port = port;
            this.serverCertificate   = certificate;
            this.useBufferedSockets  = useBufferedSockets;
            this.clientCertValidator = clientCertValidator;
            this.localCertificateSelectionCallback = localCertificateSelectionCallback;
            try
            {
                // Create server socket
                this.server = TSocketVersionizer.CreateTcpListener(port);
                this.server.Server.NoDelay = true;
            }
            catch (Exception)
            {
                server = null;
                throw new TTransportException("Could not create ServerSocket on port " + port + ".");
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="TTLSServerSocket" /> class.
        /// </summary>
        /// <param name="port">The port where the server runs.</param>
        /// <param name="clientTimeout">Send/receive timeout.</param>
        /// <param name="useBufferedSockets">If set to <c>true</c> [use buffered sockets].</param>
        /// <param name="certificate">The certificate object.</param>
        /// <param name="clientCertValidator">The certificate validator.</param>
        /// <param name="localCertificateSelectionCallback">The callback to select which certificate to use.</param>
        /// <param name="sslProtocols">The SslProtocols value that represents the protocol used for authentication.</param>
        public TTLSServerSocket(
            int port,
            int clientTimeout,
            bool useBufferedSockets,
            X509Certificate2 certificate,
            RemoteCertificateValidationCallback clientCertValidator             = null,
            LocalCertificateSelectionCallback localCertificateSelectionCallback = null,
            // TODO: Enable Tls11 and Tls12 (TLS 1.1 and 1.2) by default once we start using .NET 4.5+.
            SslProtocols sslProtocols = SslProtocols.Tls)
        {
            if (!certificate.HasPrivateKey)
            {
                throw new TTransportException(TTransportException.ExceptionType.Unknown, "Your server-certificate needs to have a private key");
            }

            this.port                = port;
            this.clientTimeout       = clientTimeout;
            this.serverCertificate   = certificate;
            this.useBufferedSockets  = useBufferedSockets;
            this.clientCertValidator = clientCertValidator;
            this.localCertificateSelectionCallback = localCertificateSelectionCallback;
            this.sslProtocols = sslProtocols;
            try
            {
                // Create server socket
                this.server = TSocketVersionizer.CreateTcpListener(this.port);
                this.server.Server.NoDelay = true;
            }
            catch (Exception)
            {
                server = null;
                throw new TTransportException("Could not create ServerSocket on port " + this.port + ".");
            }
        }
Ejemplo n.º 3
0
 public TServerSocket(Int32 port, Int32 clientTimeout, Boolean useBufferedSockets)
 {
     this.port               = port;
     this.clientTimeout      = clientTimeout;
     this.useBufferedSockets = useBufferedSockets;
     try
     {
         // Make server socket
         server = TSocketVersionizer.CreateTcpListener(this.port);
         server.Server.NoDelay = true;
     }
     catch (Exception ex)
     {
         server = null;
         throw new TTransportException("Could not create ServerSocket on port " + this.port + ".", ex);
     }
 }
Ejemplo n.º 4
0
 public TServerSocket(int port, int clientTimeout, bool useBufferedSockets)
 {
     this.port               = port;
     this.clientTimeout      = clientTimeout;
     this.useBufferedSockets = useBufferedSockets;
     try
     {
         // Make server socket
         this.server = TSocketVersionizer.CreateTcpListener(port);
         this.server.Server.NoDelay = true;
     }
     catch (Exception)
     {
         server = null;
         throw new TTransportException("Could not create ServerSocket on port " + port + ".");
     }
 }