29
29
// Copyright (c) 2007-2020 VMware, Inc. All rights reserved.
30
30
//---------------------------------------------------------------------------
31
31
32
- using System ;
33
32
using System . IO ;
34
33
using System . Net . Security ;
35
34
using System . Security . Authentication ;
@@ -60,32 +59,26 @@ public void TestServerVerifiedIgnoringNameMismatch()
60
59
{
61
60
Skip . IfNot ( _sslEnv . IsSslConfigured , "SSL_CERTS_DIR and/or PASSWORD are not configured, skipping test" ) ;
62
61
63
- ConnectionFactory ConnectionFactoryConfigurator ( ConnectionFactory cf )
64
- {
65
- cf . Port = 5671 ;
66
- cf . Ssl . ServerName = "*" ;
67
- cf . Ssl . AcceptablePolicyErrors = SslPolicyErrors . RemoteCertificateNameMismatch ;
68
- cf . Ssl . Enabled = true ;
69
- return cf ;
70
- }
62
+ ConnectionFactory cf = CreateConnectionFactory ( ) ;
63
+ cf . Port = 5671 ;
64
+ cf . Ssl . ServerName = "*" ;
65
+ cf . Ssl . AcceptablePolicyErrors = SslPolicyErrors . RemoteCertificateNameMismatch ;
66
+ cf . Ssl . Enabled = true ;
71
67
72
- SendReceive ( ConnectionFactoryConfigurator ) ;
68
+ SendReceive ( cf ) ;
73
69
}
74
70
75
71
[ SkippableFact ]
76
72
public void TestServerVerified ( )
77
73
{
78
74
Skip . IfNot ( _sslEnv . IsSslConfigured , "SSL_CERTS_DIR and/or PASSWORD are not configured, skipping test" ) ;
79
75
80
- ConnectionFactory ConnectionFactoryConfigurator ( ConnectionFactory cf )
81
- {
82
- cf . Port = 5671 ;
83
- cf . Ssl . ServerName = _sslEnv . Hostname ;
84
- cf . Ssl . Enabled = true ;
85
- return cf ;
86
- }
76
+ ConnectionFactory cf = CreateConnectionFactory ( ) ;
77
+ cf . Port = 5671 ;
78
+ cf . Ssl . ServerName = _sslEnv . Hostname ;
79
+ cf . Ssl . Enabled = true ;
87
80
88
- SendReceive ( ConnectionFactoryConfigurator ) ;
81
+ SendReceive ( cf ) ;
89
82
}
90
83
91
84
[ SkippableFact ]
@@ -96,17 +89,14 @@ public void TestClientAndServerVerified()
96
89
string certPath = _sslEnv . CertPath ;
97
90
Assert . True ( File . Exists ( certPath ) ) ;
98
91
99
- ConnectionFactory ConnectionFactoryConfigurator ( ConnectionFactory cf )
100
- {
101
- cf . Port = 5671 ;
102
- cf . Ssl . ServerName = _sslEnv . Hostname ;
103
- cf . Ssl . CertPath = certPath ;
104
- cf . Ssl . CertPassphrase = _sslEnv . CertPassphrase ;
105
- cf . Ssl . Enabled = true ;
106
- return cf ;
107
- }
92
+ ConnectionFactory cf = CreateConnectionFactory ( ) ;
93
+ cf . Port = 5671 ;
94
+ cf . Ssl . ServerName = _sslEnv . Hostname ;
95
+ cf . Ssl . CertPath = certPath ;
96
+ cf . Ssl . CertPassphrase = _sslEnv . CertPassphrase ;
97
+ cf . Ssl . Enabled = true ;
108
98
109
- SendReceive ( ConnectionFactoryConfigurator ) ;
99
+ SendReceive ( cf ) ;
110
100
}
111
101
112
102
// rabbitmq/rabbitmq-dotnet-client#46, also #44 and #45
@@ -115,28 +105,25 @@ public void TestNoClientCertificate()
115
105
{
116
106
Skip . IfNot ( _sslEnv . IsSslConfigured , "SSL_CERTS_DIR and/or PASSWORD are not configured, skipping test" ) ;
117
107
118
- ConnectionFactory ConnectionFactoryConfigurator ( ConnectionFactory cf )
108
+ ConnectionFactory cf = CreateConnectionFactory ( ) ;
109
+ cf . Port = 5671 ;
110
+ cf . Ssl = new SslOption ( )
119
111
{
120
- cf . Port = 5671 ;
121
- cf . Ssl = new SslOption ( )
122
- {
123
- CertPath = null ,
124
- Enabled = true ,
125
- ServerName = _sslEnv . Hostname ,
126
- Version = SslProtocols . None ,
127
- AcceptablePolicyErrors =
128
- SslPolicyErrors . RemoteCertificateNotAvailable |
129
- SslPolicyErrors . RemoteCertificateNameMismatch
130
- } ;
131
- return cf ;
132
- }
133
-
134
- SendReceive ( ConnectionFactoryConfigurator ) ;
112
+ CertPath = null ,
113
+ Enabled = true ,
114
+ ServerName = _sslEnv . Hostname ,
115
+ Version = SslProtocols . None ,
116
+ AcceptablePolicyErrors =
117
+ SslPolicyErrors . RemoteCertificateNotAvailable |
118
+ SslPolicyErrors . RemoteCertificateNameMismatch
119
+ } ;
120
+
121
+ SendReceive ( cf ) ;
135
122
}
136
123
137
- private void SendReceive ( Func < ConnectionFactory , ConnectionFactory > cfconfig )
124
+ private void SendReceive ( ConnectionFactory connectionFactory )
138
125
{
139
- using ( IConnection conn = CreateConnectionWithRetries ( cfconfig ) )
126
+ using ( IConnection conn = CreateConnectionWithRetries ( connectionFactory ) )
140
127
{
141
128
using ( IChannel ch = conn . CreateChannel ( ) )
142
129
{
0 commit comments