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,32 @@ 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 )
62+ var cf = new ConnectionFactory
6463 {
65- cf . Port = 5671 ;
66- cf . Ssl . ServerName = "*" ;
67- cf . Ssl . AcceptablePolicyErrors = SslPolicyErrors . RemoteCertificateNameMismatch ;
68- cf . Ssl . Enabled = true ;
69- return cf ;
70- }
64+ Port = 5671
65+ } ;
66+
67+ cf . Ssl . ServerName = "*" ;
68+ cf . Ssl . AcceptablePolicyErrors = SslPolicyErrors . RemoteCertificateNameMismatch ;
69+ cf . Ssl . Enabled = true ;
7170
72- SendReceive ( ConnectionFactoryConfigurator ) ;
71+ SendReceive ( cf ) ;
7372 }
7473
7574 [ SkippableFact ]
7675 public void TestServerVerified ( )
7776 {
7877 Skip . IfNot ( _sslEnv . IsSslConfigured , "SSL_CERTS_DIR and/or PASSWORD are not configured, skipping test" ) ;
7978
80- ConnectionFactory ConnectionFactoryConfigurator ( ConnectionFactory cf )
79+ var cf = new ConnectionFactory
8180 {
82- cf . Port = 5671 ;
83- cf . Ssl . ServerName = _sslEnv . Hostname ;
84- cf . Ssl . Enabled = true ;
85- return cf ;
86- }
81+ Port = 5671 ,
82+ } ;
8783
88- SendReceive ( ConnectionFactoryConfigurator ) ;
84+ cf . Ssl . ServerName = _sslEnv . Hostname ;
85+ cf . Ssl . Enabled = true ;
86+
87+ SendReceive ( cf ) ;
8988 }
9089
9190 [ SkippableFact ]
@@ -96,17 +95,17 @@ public void TestClientAndServerVerified()
9695 string certPath = _sslEnv . CertPath ;
9796 Assert . True ( File . Exists ( certPath ) ) ;
9897
99- ConnectionFactory ConnectionFactoryConfigurator ( ConnectionFactory cf )
98+ var cf = new ConnectionFactory
10099 {
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- }
100+ Port = 5671
101+ } ;
108102
109- SendReceive ( ConnectionFactoryConfigurator ) ;
103+ cf . Ssl . ServerName = _sslEnv . Hostname ;
104+ cf . Ssl . CertPath = certPath ;
105+ cf . Ssl . CertPassphrase = _sslEnv . CertPassphrase ;
106+ cf . Ssl . Enabled = true ;
107+
108+ SendReceive ( cf ) ;
110109 }
111110
112111 // rabbitmq/rabbitmq-dotnet-client#46, also #44 and #45
@@ -115,28 +114,28 @@ public void TestNoClientCertificate()
115114 {
116115 Skip . IfNot ( _sslEnv . IsSslConfigured , "SSL_CERTS_DIR and/or PASSWORD are not configured, skipping test" ) ;
117116
118- ConnectionFactory ConnectionFactoryConfigurator ( ConnectionFactory cf )
117+ var cf = new ConnectionFactory
119118 {
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- }
119+ Port = 5671
120+ } ;
133121
134- SendReceive ( ConnectionFactoryConfigurator ) ;
122+ cf . Ssl = new SslOption ( )
123+ {
124+ CertPath = null ,
125+ Enabled = true ,
126+ ServerName = _sslEnv . Hostname ,
127+ Version = SslProtocols . None ,
128+ AcceptablePolicyErrors =
129+ SslPolicyErrors . RemoteCertificateNotAvailable |
130+ SslPolicyErrors . RemoteCertificateNameMismatch
131+ } ;
132+
133+ SendReceive ( cf ) ;
135134 }
136135
137- private void SendReceive ( Func < ConnectionFactory , ConnectionFactory > cfconfig )
136+ private void SendReceive ( ConnectionFactory connectionFactory )
138137 {
139- using ( IConnection conn = CreateConnectionWithRetries ( cfconfig ) )
138+ using ( IConnection conn = CreateConnectionWithRetries ( connectionFactory ) )
140139 {
141140 using ( IChannel ch = conn . CreateChannel ( ) )
142141 {
0 commit comments