Skip to content

Commit ee571af

Browse files
Fix | Skip the CRL check during authenticaiton (#1559) (#1718)
1 parent fc4216e commit ee571af

File tree

2 files changed

+22
-20
lines changed

2 files changed

+22
-20
lines changed

src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/SNINpHandle.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ public override uint EnableSsl(uint options)
312312
_validateCert = (options & TdsEnums.SNI_SSL_VALIDATE_CERTIFICATE) != 0;
313313
try
314314
{
315-
_sslStream.AuthenticateAsClient(_targetServer, null, SupportedProtocols, true);
315+
_sslStream.AuthenticateAsClient(_targetServer, null, SupportedProtocols, false);
316316
_sslOverTdsStream.FinishHandshake();
317317
}
318318
catch (AuthenticationException aue)

src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/SNITcpHandle.cs

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)