Skip to content

Commit cbf66cf

Browse files
Merge pull request #45 from rabbitmq/bug-ssl-version-check
Revert client authentication changes in 36efc00
2 parents 2129fe5 + f5e7380 commit cbf66cf

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

projects/client/RabbitMQ.Client/src/client/api/SslHelper.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,7 @@ public static Stream TcpUpgrade(Stream tcpStream, SslOption sslOption)
7272

7373
var sslStream = new SslStream(tcpStream, false, remoteCertValidator, localCertSelector);
7474

75-
if(sslOption.Certs == null || sslOption.Certs.Count == 0)
76-
{
77-
sslStream.AuthenticateAsClient(sslOption.ServerName);
78-
} else
79-
{
80-
sslStream.AuthenticateAsClient(sslOption.ServerName, sslOption.Certs, sslOption.Version, false);
81-
}
75+
sslStream.AuthenticateAsClient(sslOption.ServerName, sslOption.Certs, sslOption.Version, false);
8276

8377
return sslStream;
8478
}

projects/client/Unit/src/unit/TestSsl.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@
4141
using NUnit.Framework;
4242
using System;
4343
using System.Net.Security;
44+
using System.Security.Authentication;
4445
using RabbitMQ.Client;
46+
using RabbitMQ.Client.Exceptions;
4547

4648
namespace RabbitMQ.Client.Unit
4749
{
@@ -92,6 +94,22 @@ public void TestServerVerified() {
9294
SendReceive(cf);
9395
}
9496

97+
[Test]
98+
public void TestVersionVerified() {
99+
string sslDir = Environment.GetEnvironmentVariable("SSL_CERTS_DIR");
100+
if (null == sslDir) return;
101+
102+
ConnectionFactory cf = new ConnectionFactory();
103+
cf.Ssl.Version = SslProtocols.Ssl2;
104+
cf.Ssl.AcceptablePolicyErrors = (SslPolicyErrors)~0;
105+
cf.Ssl.ServerName = "*";
106+
cf.Ssl.Enabled = true;
107+
Assert.Throws<BrokerUnreachableException>(() => SendReceive(cf));
108+
109+
cf.Ssl.Version = SslProtocols.Default;
110+
Assert.DoesNotThrow(() => SendReceive(cf));
111+
}
112+
95113
[Test]
96114
public void TestClientAndServerVerified() {
97115
string sslDir = Environment.GetEnvironmentVariable("SSL_CERTS_DIR");

0 commit comments

Comments
 (0)