File tree Expand file tree Collapse file tree 1 file changed +2
-4
lines changed
src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient Expand file tree Collapse file tree 1 file changed +2
-4
lines changed Original file line number Diff line number Diff line change @@ -1134,10 +1134,8 @@ private PreLoginHandshakeStatus ConsumePreLoginHandshake(SqlAuthenticationMethod
11341134
11351135 UInt32 error = 0;
11361136
1137- // If we're using legacy server certificate validation behavior (Authentication keyword not provided and not using access token), then validate if
1138- // Encrypt=true and Trust Sever Certificate = false.
1139- // If using Authentication keyword or access token, validate if Trust Server Certificate=false.
1140- bool shouldValidateServerCert = (encrypt && !trustServerCert) || ((authType != SqlAuthenticationMethod.NotSpecified || _connHandler._accessTokenInBytes != null) && !trustServerCert);
1137+ // Validate Certificate if Trust Server Certificate=false and Encryption forced (EncryptionOptions.ON) from Server.
1138+ bool shouldValidateServerCert = (_encryptionOption == EncryptionOptions.ON && !trustServerCert) || ((authType != SqlAuthenticationMethod.NotSpecified || _connHandler._accessTokenInBytes != null) && !trustServerCert);
11411139
11421140 UInt32 info = (shouldValidateServerCert ? TdsEnums.SNI_SSL_VALIDATE_CERTIFICATE : 0)
11431141 | (isYukonOrLater && (_encryptionOption & EncryptionOptions.CLIENT_CERT) == 0 ? TdsEnums.SNI_SSL_USE_SCHANNEL_CACHE : 0);
You can’t perform that action at this time.
0 commit comments