Repository navigation
[8.0.0 Cherry-pick] Connection encryption info – Slice A: public API surface - #5037
Merged
Merged
Conversation
* Add connection encryption info public API surface (Slice A) Adds SqlConnectionEncryptionInfo, SqlConnectionEncryptionMode, and SqlServerCertificateValidationErrors, plus SqlConnection.EncryptionInfo and SqlException.EncryptionInfo getters. In this slice both getters always return an empty snapshot; no TdsParser/SNI plumbing yet. Related to #2353. Co-authored-by: Copilot App <[email protected]> * Use SHA-256 certificate hash in SqlConnectionEncryptionInfo; add design note Replace PresentedServerCertificateThumbprint (string?) with PresentedServerCertificateHash256 (ReadOnlyMemory<byte>?), per the API agreed with the SSMS team. The internal constructor validates the hash is 32 bytes and keeps a private copy. Add doc/design-notes/2353 for reviewers. Co-authored-by: Copilot App <[email protected]> * Fix doc include path and slice plan in design note Co-authored-by: Copilot App <[email protected]> * Add NegotiatedCipherSuite to SqlConnectionEncryptionInfo Adds int? NegotiatedCipherSuite (IANA TLS cipher suite identifier selected by the server) to the public snapshot, ref assembly, XML docs, design note and unit tests. Proposal pending API review. Co-authored-by: Copilot App <[email protected]> * Cipher suite: NegotiatedCipherSuiteId (int?) on all TFMs; TlsCipherSuite? on .NET (review feedback) - Add NegotiatedCipherSuiteId (int?, CLS-compliant) on every target framework. It returns the IANA identifier unchanged, including unnamed/GREASE values. - On .NET only, NegotiatedCipherSuite exposes the same value as System.Net.Security.TlsCipherSuite? and is marked [CLSCompliant(false)]. - No NegotiatedCipherSuite member on net462/netstandard2.0, so the only shared member has an identical signature across the netstandard2.0 ref and the net10.0 implementation. - The internal constructor still takes int? (0..0xFFFF). The internal NegotiatedCipherSuiteValue is removed. - Update ref, XML docs, design note and unit tests. Copilot-Session: c47d6846-090b-4240-9f75-efa50beb8e34 Co-authored-by: Copilot App <[email protected]> * Encryption info: replace certificate hash with GetServerCertificate() (threat model review) Remove PresentedServerCertificateHash256 and expose the server-presented leaf certificate via X509Certificate2? GetServerCertificate(). Each call returns a new caller-owned instance parsed from a private DER copy, or null when no certificate was captured or the bytes cannot be parsed. The internal ctor now takes byte[]? presentedServerCertificate, and PresentedServerCertificateRawData exposes the captured bytes internally. Update ref, XML docs, design note and unit tests. Copilot-Session: c47d6846-090b-4240-9f75-efa50beb8e34 Co-authored-by: Copilot App <[email protected]> * Encryption info tests: register SqlErrorCollection known types for DataContract round trip Since #4622, SqlException.GetObjectData writes the error collection, so DataContractSerializer needs SqlErrorCollection, SqlError and List<object> as known types. Copilot-Session: c47d6846-090b-4240-9f75-efa50beb8e34 Co-authored-by: Copilot App <[email protected]> * Encryption info: address Slice A review feedback - Sort SqlConnectionEncryptionInfo public members alphabetically in the implementation, reference assembly, XML doc snippets and design note. - Document how each SqlConnectionEncryptionMode value is negotiated and how much of the connection TLS covers. - Clarify that the internal PresentedServerCertificateRawData wraps the snapshot's private copy and must not be mutated. - Add XML docs to the test constants and helpers. Copilot-Session: c47d6846-090b-4240-9f75-efa50beb8e34 Co-authored-by: Copilot App <[email protected]> * Docs: make SqlConnectionEncryptionInfo type remarks release-neutral Remove the statement that the driver never populates the snapshot; it becomes inaccurate once capture lands in later slices. Point to the getter remarks for when values are captured. Copilot-Session: c47d6846-090b-4240-9f75-efa50beb8e34 Co-authored-by: Copilot App <[email protected]> * Docs: clarify negotiated protocol availability on failure Describe null as unavailable, not proof that no TLS handshake completed, and document that a protocol observed before a later handshake or connection failure is retained. Copilot-Session: c47d6846-090b-4240-9f75-efa50beb8e34 Co-authored-by: Copilot App <[email protected]> * Docs: mark encryption info API approved Update the design note to show the approved API and remove outdated review caveats. Replace Slice A-only empty-snapshot wording in the getter remarks with the stable connection and exception snapshot contracts. Copilot-Session: c47d6846-090b-4240-9f75-efa50beb8e34 Co-authored-by: Copilot App <[email protected]> --------- Co-authored-by: Copilot App <[email protected]> Copilot-Session: c47d6846-090b-4240-9f75-efa50beb8e34
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
paulmedynski
force-pushed
the
dev/automation/pr-4830-to-8.0.0
branch
from
November 11, 2026 15:28
b7ed861 to
ecfb453
Compare
mdaigle
approved these changes
Nov 11, 2026
paulmedynski
requested changes
Nov 11, 2026
Contributor
|
My review here will be addressed by @priyankatiwari08 on main and any resulting commit will be cherry-picked into this PR. |
paulmedynski
requested changes
Nov 11, 2026
paulmedynski
left a comment
Contributor
There was a problem hiding this comment.
Further comments related to the tests.
priyankatiwari08
added a commit
that referenced
this pull request
Nov 12, 2026
Follow-up to #4830 addressing review feedback on the release/8.0 cherry-pick (#5037). - Carry TlsCipherSuite end-to-end on .NET: the internal constructor takes TlsCipherSuite? and NegotiatedCipherSuite is an auto-property; .NET Framework keeps the range-checked int? identifier. - Make SqlConnectionEncryptionMode byte-backed. - Catch only CryptographicException in GetServerCertificate. - Annotate GetServerCertificate as returning X509Certificate2? in the ref. - Clarify null semantics and validation/decoding behavior in the docs and drop implementation details. - Move SqlConnection and SqlException tests into SqlConnectionTests and SqlExceptionTests, share helpers via EncryptionInfoTestData, and tighten assertions. Co-authored-by: Copilot App <[email protected]>
Follow-up to #4830 addressing review feedback on the release/8.0 cherry-pick (#5037). - Carry TlsCipherSuite end-to-end on .NET: the internal constructor takes TlsCipherSuite? and NegotiatedCipherSuite is an auto-property; .NET Framework keeps the range-checked int? identifier. - Make SqlConnectionEncryptionMode byte-backed. - Catch only CryptographicException in GetServerCertificate. - Annotate GetServerCertificate as returning X509Certificate2? in the ref. - Clarify null semantics and validation/decoding behavior in the docs and drop implementation details. - Move SqlConnection and SqlException tests into SqlConnectionTests and SqlExceptionTests, share helpers via EncryptionInfoTestData, and tighten assertions. Co-authored-by: Copilot App <[email protected]> (cherry picked from commit 4114d5c)
GenAPI reproduces the '?' on SqlConnectionEncryptionInfo.GetServerCertificate() but emitted no '#nullable' context into the auto-generated source (CS8669) and copied the compiler-reserved NullableContextAttribute on net10.0 (CS8335). Pass a header file that adds '#nullable enable annotations', matching the ref assembly, and exclude the Nullable/NullableContext attributes from the output. Co-authored-by: Copilot App <[email protected]> (cherry picked from commit b172dc5)
- Take ushort in the cipher suite identifier theories so InlineData cannot exceed 16 bits. - Document why the BinaryFormatter SqlException tests are .NET Framework only. Co-authored-by: Copilot App <[email protected]> (cherry picked from commit ce8508d)
paulmedynski
approved these changes
Nov 12, 2026
paulmedynski
pushed a commit
that referenced
this pull request
Nov 12, 2026
* Address Slice A review feedback for connection encryption info Follow-up to #4830 addressing review feedback on the release/8.0 cherry-pick (#5037). - Carry TlsCipherSuite end-to-end on .NET: the internal constructor takes TlsCipherSuite? and NegotiatedCipherSuite is an auto-property; .NET Framework keeps the range-checked int? identifier. - Make SqlConnectionEncryptionMode byte-backed. - Catch only CryptographicException in GetServerCertificate. - Annotate GetServerCertificate as returning X509Certificate2? in the ref. - Clarify null semantics and validation/decoding behavior in the docs and drop implementation details. - Move SqlConnection and SqlException tests into SqlConnectionTests and SqlExceptionTests, share helpers via EncryptionInfoTestData, and tighten assertions. Co-authored-by: Copilot App <[email protected]> * Fix notsupported build for nullable-annotated ref members GenAPI reproduces the '?' on SqlConnectionEncryptionInfo.GetServerCertificate() but emitted no '#nullable' context into the auto-generated source (CS8669) and copied the compiler-reserved NullableContextAttribute on net10.0 (CS8335). Pass a header file that adds '#nullable enable annotations', matching the ref assembly, and exclude the Nullable/NullableContext attributes from the output. Co-authored-by: Copilot App <[email protected]> * Address second-round review feedback on Slice A follow-up - Take ushort in the cipher suite identifier theories so InlineData cannot exceed 16 bits. - Document why the BinaryFormatter SqlException tests are .NET Framework only. Co-authored-by: Copilot App <[email protected]> --------- Co-authored-by: Copilot App <[email protected]>
saurabh500
added a commit
that referenced
this pull request
Nov 17, 2026
…lic API surface (#5037)" (#5090) This reverts commit b99cd83. Co-authored-by: Saurabh Singh (SQL Drivers) <[email protected]> Co-authored-by: Copilot App <[email protected]>
This was referenced Nov 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Cherry-pick of #4830 (d8a60de) into
release/8.0.Update: This PR now also includes b457732, 93d5fd3 and b65fa83, cherry-picks of 4114d5c, b172dc5 and ce8508d from #5043 (Slice A review follow-up on
main), which addresses the review feedback on this PR.