You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit c8b5604
Browse filesBrowse the repository at this point in the historyBrowse files
authored
[6.1.8 Cherry-pick] Honor HostNameInCertificate in managed SNI certificate validation (#4909)
* Honor HostNameInCertificate in managed SNI certificate validation (#4905)
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 18415205-5120-4f0e-9815-f2325898516c
* Fix certificate validation test compatibility in 6.1 backport
Use the .NET 8 certificate import fallback and branch-compatible nullable annotations. Register the manual hostname test in set 1 and construct connections using the release-branch API.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: d02b81a2-8d04-492b-8fc8-66d4dbb020f5
---------
Co-authored-by: Apoorv Deshmukh <apdeshmukh@microsoft.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Priyanka Tiwari <prtiwar@microsoft.com>
Copilot-Session: 18415205-5120-4f0e-9815-f2325898516c
Copilot-Session: d02b81a2-8d04-492b-8fc8-66d4dbb020f5
Copy file name to clipboardExpand all lines: doc/snippets/Microsoft.Data.SqlClient/SqlConnectionStringBuilder.xml
+4Lines changed: 4 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -732,6 +732,10 @@ This property corresponds to the "FailoverPartnerSPN" and "Failover Partner SPN"
732
732
<![CDATA[
733
733
This property corresponds to the "HostNameInCertificate" and "Host Name in Certificate" keys within the connection string.
734
734
735
+
When certificate hostname validation is performed, an explicitly supplied value is the only
736
+
expected hostname. It replaces the hostname from `Data Source` for that validation without
737
+
changing the connection destination.
738
+
735
739
> [!NOTE]
736
740
> This property only applies when using `Encrypt` in <xref:Microsoft.Data.SqlClient.SqlConnectionEncryptOption.Mandatory%2A> or <xref:Microsoft.Data.SqlClient.SqlConnectionEncryptOption.Strict%2A> mode, otherwise it is ignored.
Copy file name to clipboardExpand all lines: src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ManagedSni/SniCommon.netcore.cs
+16-11Lines changed: 16 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -43,9 +43,9 @@ internal class SniCommon
43
43
internalconstintLocalDBBadRuntime=57;
44
44
45
45
/// <summary>
46
-
/// We either validate that the provided 'validationCert' matches the 'serverCert', or we validate that the server name in the 'serverCert' matches 'targetServerName'.
47
-
/// Certificate validation and chain trust validations are done by SSLStream class [System.Net.Security.SecureChannel.VerifyRemoteCertificate method]
48
-
/// This method is called as a result of callback for SSL Stream Certificate validation.
46
+
/// Validates an exact certificate pin or the expected certificate hostname.
47
+
/// An explicit hostname replaces the target server name for hostname validation.
48
+
/// Certificate-chain policy errors are supplied by the SslStream validation callback.
49
49
/// </summary>
50
50
/// <remarks>
51
51
/// When <paramref name="validationCertFileName"/> is supplied, the presented server
SqlClientEventSource.Log.TrySNITraceEvent(nameof(SniCommon),EventType.INFO,"Connection Id {0}, targetServerName {1}, SSL Server certificate has no policy errors and no ServerCertificate was supplied; skipping certificate comparison.",args0:connectionId,args1:targetServerName);
80
+
SqlClientEventSource.Log.TrySNITraceEvent(nameof(SniCommon),EventType.INFO,"Connection Id {0}, targetServerName {1}, SSL Server certificate has no policy errors and no HostNameInCertificate or ServerCertificate was supplied; skipping certificate comparison.",args0:connectionId,args1:targetServerName);
SqlClientEventSource.Log.TrySNITraceEvent(nameof(SniCommon),EventType.ERR,"Connection Id {0}, targetServerName {1}, SSL Server certificate not validated as PolicyErrors set to RemoteCertificateNotAvailable.",args0:connectionId,args1:targetServerName);
0 commit comments