2929// Copyright (c) 2007-2020 VMware, Inc. All rights reserved.
3030//---------------------------------------------------------------------------
3131
32- using System ;
3332using System . IO ;
3433using System . Net . Security ;
3534using System . Security . Authentication ;
@@ -60,32 +59,26 @@ public void TestServerVerifiedIgnoringNameMismatch()
6059 {
6160 Skip . IfNot ( _sslEnv . IsSslConfigured , "SSL_CERTS_DIR and/or PASSWORD are not configured, skipping test" ) ;
6261
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 ;
7167
72- SendReceive ( ConnectionFactoryConfigurator ) ;
68+ SendReceive ( cf ) ;
7369 }
7470
7571 [ SkippableFact ]
7672 public void TestServerVerified ( )
7773 {
7874 Skip . IfNot ( _sslEnv . IsSslConfigured , "SSL_CERTS_DIR and/or PASSWORD are not configured, skipping test" ) ;
7975
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 ;
8780
88- SendReceive ( ConnectionFactoryConfigurator ) ;
81+ SendReceive ( cf ) ;
8982 }
9083
9184 [ SkippableFact ]
@@ -96,17 +89,14 @@ public void TestClientAndServerVerified()
9689 string certPath = _sslEnv . CertPath ;
9790 Assert . True ( File . Exists ( certPath ) ) ;
9891
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 ;
10898
109- SendReceive ( ConnectionFactoryConfigurator ) ;
99+ SendReceive ( cf ) ;
110100 }
111101
112102 // rabbitmq/rabbitmq-dotnet-client#46, also #44 and #45
@@ -115,28 +105,25 @@ public void TestNoClientCertificate()
115105 {
116106 Skip . IfNot ( _sslEnv . IsSslConfigured , "SSL_CERTS_DIR and/or PASSWORD are not configured, skipping test" ) ;
117107
118- ConnectionFactory ConnectionFactoryConfigurator ( ConnectionFactory cf )
108+ ConnectionFactory cf = CreateConnectionFactory ( ) ;
109+ cf . Port = 5671 ;
110+ cf . Ssl = new SslOption ( )
119111 {
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 ) ;
135122 }
136123
137- private void SendReceive ( Func < ConnectionFactory , ConnectionFactory > cfconfig )
124+ private void SendReceive ( ConnectionFactory connectionFactory )
138125 {
139- using ( IConnection conn = CreateConnectionWithRetries ( cfconfig ) )
126+ using ( IConnection conn = CreateConnectionWithRetries ( connectionFactory ) )
140127 {
141128 using ( IChannel ch = conn . CreateChannel ( ) )
142129 {
0 commit comments