public void TestThatHeartbeatWriterWithTLSEnabled()
        {
            if (!LongRunningTestsEnabled())
            {
                Console.WriteLine("RABBITMQ_LONG_RUNNING_TESTS is not set, skipping test");
                return;
            }

            var cf = new ConnectionFactory()
            {
                RequestedHeartbeat       = _heartbeatTimeout,
                AutomaticRecoveryEnabled = false
            };

            string sslDir = IntegrationFixture.CertificatesDirectory();

            if (null == sslDir)
            {
                Console.WriteLine("SSL_CERT_DIR is not configured, skipping test");
                return;
            }
            cf.Ssl.ServerName = System.Net.Dns.GetHostName();
            Assert.IsNotNull(sslDir);
            cf.Ssl.CertPath = sslDir + "/client/keycert.p12";
            string p12Password = Environment.GetEnvironmentVariable("PASSWORD");

            Assert.IsNotNull(p12Password, "missing PASSWORD env var");
            cf.Ssl.CertPassphrase = p12Password;
            cf.Ssl.Enabled        = true;

            RunSingleConnectionTest(cf);
        }
        public void TestNoClientCertificate()
        {
            string sslDir = IntegrationFixture.CertificatesDirectory();

            if (null == sslDir)
            {
                Console.WriteLine("SSL_CERT_DIR is not configured, skipping test");
                return;
            }

            ConnectionFactory cf = new ConnectionFactory();

            cf.Ssl = new SslOption()
            {
                CertPath = null,
                Enabled  = true,
            };

#if !NETFX_CORE
            cf.Ssl.Version = SslProtocols.Tls;
            cf.Ssl.AcceptablePolicyErrors = SslPolicyErrors.RemoteCertificateNotAvailable |
                                            SslPolicyErrors.RemoteCertificateNameMismatch;
#endif

            SendReceive(cf);
        }
        public void TestThatHeartbeatWriterWithTLSEnabled()
        {
            Skip.IfNot(LongRunningTestsEnabled(), "RABBITMQ_LONG_RUNNING_TESTS is not set, skipping test");

            var cf = new ConnectionFactory()
            {
                Port = 5671,
                RequestedHeartbeat       = _heartbeatTimeout,
                AutomaticRecoveryEnabled = false
            };

            string sslDir         = IntegrationFixture.CertificatesDirectory();
            string certPassphrase = Environment.GetEnvironmentVariable("PASSWORD");
            bool   sslConfigured  = Directory.Exists(sslDir) &&
                                    (false == string.IsNullOrEmpty(certPassphrase));

            Skip.IfNot(sslConfigured, "SSL_CERTS_DIR and/or PASSWORD are not configured, skipping test");

            string hostName = System.Net.Dns.GetHostName();

            cf.Ssl.ServerName     = hostName;
            cf.Ssl.CertPath       = $"{sslDir}/client_{hostName}_key.p12";
            cf.Ssl.CertPassphrase = certPassphrase;
            cf.Ssl.Enabled        = true;

            RunSingleConnectionTest(cf);
        }
Example #4
0
        public TestSsl(ITestOutputHelper output)
        {
            _output = output;
            var type       = _output.GetType();
            var testMember = type.GetField("test", BindingFlags.Instance | BindingFlags.NonPublic);
            var test       = (ITest)testMember.GetValue(output);

            _testDisplayName = test.DisplayName;

            _sslDir         = IntegrationFixture.CertificatesDirectory();
            _certPassphrase = Environment.GetEnvironmentVariable("PASSWORD");

            _sslConfigured = Directory.Exists(_sslDir) &&
                             (false == string.IsNullOrEmpty(_certPassphrase));
        }
        public void TestServerVerified()
        {
            string sslDir = IntegrationFixture.CertificatesDirectory();

            if (null == sslDir)
            {
                Console.WriteLine("SSL_CERT_DIR is not configured, skipping test");
                return;
            }

            ConnectionFactory cf = new ConnectionFactory();

            cf.Ssl.ServerName = System.Net.Dns.GetHostName();
            cf.Ssl.Enabled    = true;
            SendReceive(cf);
        }
Example #6
0
        public void TestServerVerifiedIgnoringNameMismatch()
        {
            string sslDir = IntegrationFixture.CertificatesDirectory();

            if (null == sslDir)
            {
                Console.WriteLine("SSL_CERT_DIR is not configured, skipping test");
                return;
            }

            ConnectionFactory cf = new ConnectionFactory();

            cf.Ssl.ServerName             = "*";
            cf.Ssl.AcceptablePolicyErrors = SslPolicyErrors.RemoteCertificateNameMismatch;
            cf.Ssl.Enabled = true;
            SendReceive(cf);
        }
Example #7
0
        public void TestVersionVerified()
        {
            string sslDir = IntegrationFixture.CertificatesDirectory();

            if (null == sslDir)
            {
                Console.WriteLine("SSL_CERT_DIR is not configured, skipping test");
                return;
            }

            ConnectionFactory cf = new ConnectionFactory();

            cf.Ssl.Version = SslProtocols.Ssl2;
            cf.Ssl.AcceptablePolicyErrors = (SslPolicyErrors) ~0;
            cf.Ssl.ServerName             = "*";
            cf.Ssl.Enabled = true;
            Assert.Throws <BrokerUnreachableException>(() => SendReceive(cf));

            cf.Ssl.Version = SslProtocols.Tls12;
            Assert.DoesNotThrow(() => SendReceive(cf));
        }
        public void TestClientAndServerVerified()
        {
            string sslDir = IntegrationFixture.CertificatesDirectory();

            if (null == sslDir)
            {
                Console.WriteLine("SSL_CERT_DIR is not configured, skipping test");
                return;
            }

            ConnectionFactory cf = new ConnectionFactory();

            cf.Ssl.ServerName = System.Net.Dns.GetHostName();
            Assert.IsNotNull(sslDir);
            cf.Ssl.CertPath = sslDir + "/client/keycert.p12";
            string p12Password = Environment.GetEnvironmentVariable("PASSWORD");

            Assert.IsNotNull(p12Password, "missing PASSWORD env var");
            cf.Ssl.CertPassphrase = p12Password;
            cf.Ssl.Enabled        = true;
            SendReceive(cf);
        }