Exemplo n.º 1
0
 public void Open()
 {
     client.Connect(configuration.GetHost());
     sslStream = new SslStream(client.GetStream())
     {
         ReadTimeout  = configuration.Timeout,
         WriteTimeout = configuration.Timeout
     };
     sslStream.AuthenticateAsClient(configuration.GetServerNameInCertificate());
 }
Exemplo n.º 2
0
        public void Open()
        {
            client.Connect(configuration.GetHost());
            sslStream = new SslStream(client.GetStream())
            {
                ReadTimeout  = configuration.Timeout,
                WriteTimeout = configuration.Timeout
            };

            var x509CertificateCollection = new X509Certificate2Collection();

            if (!string.IsNullOrWhiteSpace(configuration.CertificatePath))
            {
                var certificate = new X509Certificate2(configuration.CertificatePath);
                x509CertificateCollection.Add(certificate);
            }

            sslStream.AuthenticateAsClient(configuration.GetServerNameInCertificate(), x509CertificateCollection,
                                           SslProtocols.Default, true);
        }
Exemplo n.º 3
0
        private void EstablishConnection()
        {
            if (connection != null)
            {
                return;
            }

            try
            {
                connection = createConnection();
                connection.Open();
            }
            catch (Exception exception)
            {
                Close();

                throw new CannotConnectException(string.Format("Cannot connect to {0}", configuration.GetHost()), exception);
            }
        }
Exemplo n.º 4
0
 public void Open()
 {
     client.Connect(configuration.GetHost());
     networkStream = client.GetStream();
 }