Skip to content

Commit bd1278f

Browse files
committed
Fix TLS test
1 parent 3899627 commit bd1278f

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
## RabbitMQ .NET Client
22

33
[![AppVeyor Build status](https://ci.appveyor.com/api/projects/status/33srpo7owl1h3y4e?svg=true)](https://ci.appveyor.com/project/rabbitmq/rabbitmq-dotnet-client)
4-
[![Travis CI Build Status](https://travis-ci.org/rabbitmq/rabbitmq-dotnet-client.svg?branch=master)](https://travis-ci.org/rabbitmq/rabbitmq-dotnet-client)
54

65
This repository contains source code of the [RabbitMQ .NET client](https://www.rabbitmq.com/dotnet.html).
76
The client is maintained by the [RabbitMQ team at VMware](https://github.com/rabbitmq/).

projects/Unit/TestHeartbeats.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,10 @@ public void TestThatHeartbeatWriterWithTLSEnabled()
7575
Console.WriteLine("SSL_CERTS_DIR is not configured, skipping test");
7676
return;
7777
}
78+
cf.Ssl.ServerName = System.Net.Dns.GetHostName();
7879
Assert.IsNotNull(sslDir);
79-
cf.Ssl.ServerName = "localhost";
8080
cf.Ssl.CertPath = $"{sslDir}/client_key.p12";
81-
cf.Ssl.CertPassphrase = string.Empty;
81+
cf.Ssl.CertPassphrase = Environment.GetEnvironmentVariable("PASSWORD");
8282
cf.Ssl.Enabled = true;
8383

8484
RunSingleConnectionTest(cf);

projects/Unit/TestSsl.cs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ public void TestServerVerifiedIgnoringNameMismatch()
7474
}
7575

7676
ConnectionFactory cf = new ConnectionFactory { Port = 5671 };
77-
cf.Ssl.ServerName = "localhost";
77+
cf.Ssl.ServerName = "*";
78+
cf.Ssl.AcceptablePolicyErrors = SslPolicyErrors.RemoteCertificateNameMismatch;
7879
cf.Ssl.Enabled = true;
7980
SendReceive(cf);
8081
}
@@ -90,7 +91,7 @@ public void TestServerVerified()
9091
}
9192

9293
ConnectionFactory cf = new ConnectionFactory { Port = 5671 };
93-
cf.Ssl.ServerName = "localhost";
94+
cf.Ssl.ServerName = System.Net.Dns.GetHostName();
9495
cf.Ssl.Enabled = true;
9596
SendReceive(cf);
9697
}
@@ -104,12 +105,12 @@ public void TestClientAndServerVerified()
104105
Console.WriteLine("SSL_CERTS_DIR is not configured, skipping test");
105106
return;
106107
}
107-
Assert.IsNotNull(sslDir);
108108

109109
ConnectionFactory cf = new ConnectionFactory { Port = 5671 };
110-
cf.Ssl.ServerName = "localhost";
110+
cf.Ssl.ServerName = System.Net.Dns.GetHostName();
111+
Assert.IsNotNull(sslDir);
111112
cf.Ssl.CertPath = $"{sslDir}/client_key.p12";
112-
cf.Ssl.CertPassphrase = string.Empty;
113+
cf.Ssl.CertPassphrase = Environment.GetEnvironmentVariable("PASSWORD");
113114
cf.Ssl.Enabled = true;
114115
SendReceive(cf);
115116
}
@@ -133,9 +134,13 @@ public void TestNoClientCertificate()
133134
CertPath = null,
134135
Enabled = true,
135136
ServerName = "localhost",
136-
Version = SslProtocols.None
137+
Version = SslProtocols.None,
138+
AcceptablePolicyErrors =
139+
SslPolicyErrors.RemoteCertificateNotAvailable |
140+
SslPolicyErrors.RemoteCertificateNameMismatch
137141
}
138142
};
143+
139144
SendReceive(cf);
140145
}
141146
}

0 commit comments

Comments
 (0)