Repository navigation
Connection encryption info – Slice C: Managed SNI certificate capture #4835
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
priyankatiwari08
wants to merge
12
commits into
dev/automation/encryption-info-slice-b-mode-protocol
from
dev/automation/encryption-info-slice-c-managed-sni
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
a694bec
Connection encryption info: capture Managed SNI server certificate de…
priyankatiwari08 30d3e46
Keep Managed SNI certificate verdict when the host name check throws
priyankatiwari08 6887dc3
Managed SNI: capture negotiated cipher suite
priyankatiwari08 3930309
Mark Managed SNI capture simulator failures as expected TLS handshake…
priyankatiwari08 109bc3a
Adapt Slice C tests and design note to NegotiatedCipherSuiteId
priyankatiwari08 ba2f0ac
Capture the presented server certificate instead of its hash (Managed…
priyankatiwari08 c33a3cd
Address review feedback on Managed SNI certificate capture
priyankatiwari08 e068e39
Split Managed SNI capture simulator tests into Open and OpenAsync tests
priyankatiwari08 44fe90b
Align native SNI failure note with Managed SNI capture
priyankatiwari08 7076de8
Adapt reconnect tests to Managed SNI certificate capture
priyankatiwari08 a12b6ad
Adapt Slice C tests to the Slice A review follow-up helpers
priyankatiwari08 f771fb4
Adapt Slice C to the Slice B accumulator design
priyankatiwari08 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
78 changes: 78 additions & 0 deletions
78
...rosoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Connection/ServerCertificateCapture.cs
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
| // See the LICENSE file in the project root for more information. | ||
|
|
||
| using System.Security.Authentication; | ||
| using System.Security.Cryptography.X509Certificates; | ||
|
|
||
| #nullable enable | ||
|
|
||
| namespace Microsoft.Data.SqlClient.Connection | ||
| { | ||
| /// <summary> | ||
| /// Immutable record of the server certificate details observed by the transport during one TLS | ||
| /// handshake. Produced by the transport layer and consumed by <see cref="EncryptionInfoAccumulator"/>. | ||
| /// </summary> | ||
| /// <remarks> | ||
| /// Each value is <see langword="null"/> when it is unavailable: no certificate was presented | ||
| /// or it was larger than <see cref="MaxRawCertificateSize"/> (<see cref="RawCertificate"/>), | ||
| /// SqlClient did not evaluate the certificate (<see cref="ValidationErrors"/>), or the original | ||
| /// chain was not consulted or reported no usable status (<see cref="ChainStatus"/>). | ||
| /// </remarks> | ||
| internal sealed class ServerCertificateCapture | ||
| { | ||
| /// <summary> | ||
| /// The largest DER-encoded certificate, in bytes, that is captured. A larger certificate is | ||
| /// not captured; the connection is unaffected. | ||
| /// </summary> | ||
| internal const int MaxRawCertificateSize = 64 * 1024; | ||
|
|
||
| internal ServerCertificateCapture( | ||
| byte[]? rawCertificate, | ||
| SqlServerCertificateValidationErrors? validationErrors, | ||
| X509ChainStatusFlags? chainStatus, | ||
| SslProtocols? protocol = null, | ||
| int? cipherSuite = null) | ||
| { | ||
| RawCertificate = rawCertificate; | ||
| ValidationErrors = validationErrors; | ||
| ChainStatus = chainStatus; | ||
| Protocol = protocol; | ||
| CipherSuite = cipherSuite; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Gets the DER encoding of the presented leaf certificate, or <see langword="null"/> if no | ||
| /// certificate was presented or it was larger than <see cref="MaxRawCertificateSize"/>. | ||
| /// The array is owned by this capture and must not be modified. | ||
| /// </summary> | ||
| public byte[]? RawCertificate { get; } | ||
|
|
||
| /// <summary> | ||
| /// Gets SqlClient's effective validation verdict, or <see langword="null"/> if SqlClient did | ||
| /// not evaluate the certificate. | ||
| /// </summary> | ||
| public SqlServerCertificateValidationErrors? ValidationErrors { get; } | ||
|
|
||
| /// <summary> | ||
| /// Gets the combined status flags of the chain supplied to the certificate validation | ||
| /// callback, or <see langword="null"/> if the chain was not consulted or is unavailable. | ||
| /// </summary> | ||
| public X509ChainStatusFlags? ChainStatus { get; } | ||
|
|
||
| /// <summary> | ||
| /// Gets the TLS protocol the transport reported for this handshake, or <see langword="null"/> | ||
| /// if the transport did not report one. Used only when the protocol was not otherwise | ||
| /// determined for the attempt (for example, when the handshake failed). | ||
| /// </summary> | ||
| public SslProtocols? Protocol { get; } | ||
|
|
||
| /// <summary> | ||
| /// Gets the IANA identifier of the cipher suite the transport reported for this handshake, | ||
| /// or <see langword="null"/> if the transport did not report one. Used only when the cipher | ||
| /// suite was not otherwise determined for the attempt (for example, when the handshake | ||
| /// failed). | ||
| /// </summary> | ||
| public int? CipherSuite { get; } | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.