@@ -231,10 +231,7 @@ public ConnectionSettings(Uri uri,
231231 path : "/" ,
232232 scheme : scheme ) ;
233233
234- if ( _address . UseSsl && _tlsSettings == null )
235- {
236- _tlsSettings = new TlsSettings ( ) ;
237- }
234+ _tlsSettings = InitTlsSettings ( ) ;
238235 }
239236
240237 public ConnectionSettings ( string scheme ,
@@ -255,19 +252,19 @@ public ConnectionSettings(string scheme,
255252 throw new ArgumentOutOfRangeException ( nameof ( scheme ) , "scheme must be 'amqp' or 'amqps'" ) ;
256253 }
257254
258- _address = new Address ( host : host , port : port ,
259- user : user , password : password ,
260- path : "/" , scheme : scheme ) ;
255+ _address = new Address ( host : host ,
256+ port : port ,
257+ user : user ,
258+ password : password ,
259+ path : "/" ,
260+ scheme : scheme ) ;
261261
262262 if ( virtualHost is not null )
263263 {
264264 _virtualHost = virtualHost ;
265265 }
266266
267- if ( _address . UseSsl && _tlsSettings == null )
268- {
269- _tlsSettings = new TlsSettings ( ) ;
270- }
267+ _tlsSettings = InitTlsSettings ( ) ;
271268 }
272269
273270 protected ConnectionSettings (
@@ -424,6 +421,18 @@ protected static string ProcessUriSegmentsForVirtualHost(Uri uri)
424421 }
425422 }
426423
424+ private TlsSettings ? InitTlsSettings ( )
425+ {
426+ if ( _address . UseSsl && _tlsSettings is null )
427+ {
428+ return new TlsSettings ( ) ;
429+ }
430+ else
431+ {
432+ return null ;
433+ }
434+ }
435+
427436 ///<summary>
428437 /// Unescape a string, protecting '+'.
429438 /// </summary>
0 commit comments