Ejemplo n.º 1
0
        /// <param name="Socket">Underlying socket to use</param>
        /// <param name="Serializer">Serializer to serialize messages with</param>
        /// <param name="UseSSL">Option to enable encryption of data via SSL</param>
        /// <param name="AllowInsecureCerts">Don't attempt to validate the server's certificate client side</param>
        /// <param name="ServerCertificate">Certificate to serve to the client while establishing an SSL connection</param>
        public NLCSocket(Socket Socket, ISerializationProdiver Serializer, bool UseSSL = false, bool AllowInsecureCerts = false, X509Certificate2 ServerCertificate = null)
        {
            BaseSocket = Socket;

            this.UseSSL                = UseSSL;
            this.ServerCertificate     = ServerCertificate;
            this.AllowInsecureCerts    = AllowInsecureCerts;
            this.SerializationProdiver = Serializer;

            if (BaseSocket.Connected)
            {
                if (UseSSL)
                {
                    SetupSSL();

                    SSLStream.AuthenticateAsServer(ServerCertificate, clientCertificateRequired: false, checkCertificateRevocation: true, enabledSslProtocols: SslProtocols.Tls12);
                }
            }
        }
Ejemplo n.º 2
0
 /// <param name="Serializer">Serializer to serialize messages with</param>
 /// <param name="UseSSL">Option to enable encryption of data via SSL</param>
 /// <param name="AllowInsecureCerts">Don't attempt to validate the server's certificate client side</param>
 /// <param name="ServerCertificate">Certificate to serve to the client while establishing an SSL connection</param>
 public NLCSocket(ISerializationProdiver Serializer, bool UseSSL = false, bool AllowInsecureCerts = false, X509Certificate2 ServerCertificate = null)
     : this(new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp), Serializer, UseSSL, AllowInsecureCerts, ServerCertificate)
 {
 }