Skip to content

Commit c58f6e2

Browse files
committed
Update all SSL tests to use client certs
1 parent eabe55d commit c58f6e2

File tree

6 files changed

+19
-11
lines changed

6 files changed

+19
-11
lines changed

.ci/ubuntu/gha-setup.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,8 @@ function install_ca_certificate
144144

145145
openssl s_client -connect localhost:5671 \
146146
-CAfile "$GITHUB_WORKSPACE/.ci/certs/ca_certificate.pem" \
147-
-cert "$GITHUB_WORKSPACE/.ci/certs/client_localhost_certificate.pem" \
148-
-key "$GITHUB_WORKSPACE/.ci/certs/client_localhost_key.pem" \
147+
-cert "$GITHUB_WORKSPACE/.ci/certs/client_direct_certificate.pem" \
148+
-key "$GITHUB_WORKSPACE/.ci/certs/client_direct_key.pem" \
149149
-pass pass:grapefruit < /dev/null
150150
}
151151

.ci/ubuntu/rabbitmq.conf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ loopback_users.guest = true
1111
ssl_options.verify = verify_peer
1212
ssl_options.fail_if_no_peer_cert = true
1313
ssl_options.cacertfile = /etc/rabbitmq/certs/ca_certificate.pem
14-
ssl_options.certfile = /etc/rabbitmq/certs/server_localhost_certificate.pem
15-
ssl_options.keyfile = /etc/rabbitmq/certs/server_localhost_key.pem
14+
ssl_options.certfile = /etc/rabbitmq/certs/server_direct_certificate.pem
15+
ssl_options.keyfile = /etc/rabbitmq/certs/server_direct_key.pem
1616
ssl_options.password = grapefruit

.ci/windows/gha-setup.ps1

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,11 @@ $ErrorActionPreference = 'Continue'
240240
Write-Host '[INFO] Enabling plugins...'
241241
& $rabbitmq_plugins_path enable rabbitmq_management rabbitmq_stream rabbitmq_stream_management rabbitmq_amqp1_0
242242

243-
echo Q | openssl s_client -connect localhost:5671 -CAfile "$certs_dir/ca_certificate.pem" -cert "$certs_dir/client_localhost_certificate.pem" -key "$certs_dir/client_localhost_key.pem" -pass pass:grapefruit
243+
echo Q | openssl s_client -connect localhost:5671 `
244+
-CAfile "$certs_dir/ca_certificate.pem" `
245+
-cert "$certs_dir/client_direct_certificate.pem" `
246+
-key "$certs_dir/client_direct_key.pem" `
247+
-pass pass:grapefruit
244248
if ($LASTEXITCODE -ne 0)
245249
{
246250
throw "[ERROR] 'openssl s_client' returned error: $LASTEXITCODE"

.ci/windows/rabbitmq.conf.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ loopback_users.guest = true
1010
ssl_options.verify = verify_peer
1111
ssl_options.fail_if_no_peer_cert = true
1212
ssl_options.cacertfile = @@CERTS_DIR@@/ca_certificate.pem
13-
ssl_options.certfile = @@CERTS_DIR@@/server_localhost_certificate.pem
14-
ssl_options.keyfile = @@CERTS_DIR@@/server_localhost_key.pem
13+
ssl_options.certfile = @@CERTS_DIR@@/server_direct_certificate.pem
14+
ssl_options.keyfile = @@CERTS_DIR@@/server_direct_key.pem
1515
ssl_options.password = grapefruit

projects/Test/Common/SslEnv.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public SslEnv()
5252

5353
if (_isSslConfigured)
5454
{
55-
_certPath = Path.Combine(_sslDir, $"client_{_hostname}.p12");
55+
_certPath = Path.Combine(_sslDir, $"client.p12");
5656
}
5757
}
5858

projects/Test/Integration/TestSsl.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ public async Task TestServerVerifiedIgnoringNameMismatch()
6464
ConnectionFactory cf = CreateConnectionFactory();
6565
cf.Port = 5671;
6666
cf.Ssl.ServerName = "*";
67+
cf.Ssl.CertPath = certPath;
6768
cf.Ssl.AcceptablePolicyErrors = SslPolicyErrors.RemoteCertificateNameMismatch;
6869
cf.Ssl.Enabled = true;
6970

@@ -78,6 +79,7 @@ public async Task TestServerVerified()
7879
ConnectionFactory cf = CreateConnectionFactory();
7980
cf.Port = 5671;
8081
cf.Ssl.ServerName = _sslEnv.Hostname;
82+
cf.Ssl.CertPath = certPath;
8183
cf.Ssl.Enabled = true;
8284

8385
await SendReceiveAsync(cf);
@@ -101,17 +103,19 @@ public async Task TestClientAndServerVerified()
101103
await SendReceiveAsync(cf);
102104
}
103105

104-
// rabbitmq/rabbitmq-dotnet-client#46, also #44 and #45
105106
[SkippableFact]
106-
public async Task TestNoClientCertificate()
107+
public async Task TestWithClientCertificate()
107108
{
108109
Skip.IfNot(_sslEnv.IsSslConfigured, "SSL_CERTS_DIR and/or PASSWORD are not configured, skipping test");
109110

111+
string certPath = _sslEnv.CertPath;
112+
Assert.True(File.Exists(certPath));
113+
110114
ConnectionFactory cf = CreateConnectionFactory();
111115
cf.Port = 5671;
112116
cf.Ssl = new SslOption()
113117
{
114-
CertPath = null,
118+
CertPath = certPath,
115119
Enabled = true,
116120
ServerName = _sslEnv.Hostname,
117121
Version = SslProtocols.None,

0 commit comments

Comments
 (0)