@@ -575,27 +575,29 @@ private static async void ParallelConnectHelper(
575575 /// </summary>
576576 public override uint EnableSsl ( uint options )
577577 {
578- _validateCert = ( options & TdsEnums . SNI_SSL_VALIDATE_CERTIFICATE ) != 0 ;
579-
580- try
581- {
582- _sslStream . AuthenticateAsClient ( _targetServer , null , SupportedProtocols , true ) ;
583- _sslOverTdsStream . FinishHandshake ( ) ;
584- }
585- catch ( AuthenticationException aue )
578+ using ( TrySNIEventScope . Create ( nameof ( SNIHandle ) ) )
586579 {
587- SqlClientEventSource . Log . TrySNITraceEvent ( nameof ( SNITCPHandle ) , EventType . ERR , "Connection Id {0}, Authentication exception occurred: {1}" , args0 : _connectionId , args1 : aue ? . Message ) ;
588- return ReportTcpSNIError ( aue , SNIError . CertificateValidationErrorCode ) ;
589- }
590- catch ( InvalidOperationException ioe )
591- {
592- SqlClientEventSource . Log . TrySNITraceEvent ( nameof ( SNITCPHandle ) , EventType . ERR , "Connection Id {0}, Invalid Operation Exception occurred: {1}" , args0 : _connectionId , args1 : ioe ? . Message ) ;
593- return ReportTcpSNIError ( ioe ) ;
594- }
580+ _validateCert = ( options & TdsEnums . SNI_SSL_VALIDATE_CERTIFICATE ) != 0 ;
581+ try
582+ {
583+ _sslStream . AuthenticateAsClient ( _targetServer , null , SupportedProtocols , false ) ;
584+ _sslOverTdsStream . FinishHandshake ( ) ;
585+ }
586+ catch ( AuthenticationException aue )
587+ {
588+ SqlClientEventSource . Log . TrySNITraceEvent ( nameof ( SNITCPHandle ) , EventType . ERR , "Connection Id {0}, Authentication exception occurred: {1}" , args0 : _connectionId , args1 : aue ? . Message ) ;
589+ return ReportTcpSNIError ( aue , SNIError . CertificateValidationErrorCode ) ;
590+ }
591+ catch ( InvalidOperationException ioe )
592+ {
593+ SqlClientEventSource . Log . TrySNITraceEvent ( nameof ( SNITCPHandle ) , EventType . ERR , "Connection Id {0}, Invalid Operation Exception occurred: {1}" , args0 : _connectionId , args1 : ioe ? . Message ) ;
594+ return ReportTcpSNIError ( ioe ) ;
595+ }
595596
596- _stream = _sslStream ;
597- SqlClientEventSource . Log . TrySNITraceEvent ( nameof ( SNITCPHandle ) , EventType . INFO , "Connection Id {0}, SSL enabled successfully." , args0 : _connectionId ) ;
598- return TdsEnums . SNI_SUCCESS ;
597+ _stream = _sslStream ;
598+ SqlClientEventSource . Log . TrySNITraceEvent ( nameof ( SNITCPHandle ) , EventType . INFO , "Connection Id {0}, SSL enabled successfully." , args0 : _connectionId ) ;
599+ return TdsEnums . SNI_SUCCESS ;
600+ }
599601 }
600602
601603 /// <summary>
0 commit comments