Repository navigation
Connection encryption info – Slice D: Native SNI interop #4836
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
Draft
priyankatiwari08
wants to merge
15
commits into
dev/automation/encryption-info-slice-c-managed-sni
from
dev/automation/encryption-info-slice-d-native-sni
+1,953
−45
Draft
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
1552fe9
Connection encryption info: Native SNI certificate capture (Slice D)
priyankatiwari08 ce37b05
Test: native deferred-validation failure keeps certificate fields aft…
priyankatiwari08 fc4a00b
Slice D: keep observed negotiation on native validation failure (G2/D15)
priyankatiwari08 b91c796
Design note: native deferred validation is always on; remove fixed na…
priyankatiwari08 b88da06
Capture the negotiated cipher suite from native SNI
priyankatiwari08 8133c1a
Slice D: import NativeSni namespace after main's TDS parser refactor …
priyankatiwari08 44ada10
Adapt Slice D tests and design note to NegotiatedCipherSuiteId
priyankatiwari08 56b913b
Capture the presented server certificate from native SNI instead of i…
priyankatiwari08 5dc63ac
Add live native SNI server certificate test
priyankatiwari08 c1448c0
Address Slice D review feedback
priyankatiwari08 9cf1e74
Adapt ConnectionEncryptionInfoTests to native certificate capture
priyankatiwari08 4a3d7d8
Design note: reconcile native SNI failure path with deferred validation
priyankatiwari08 7c400e8
Test: native cipher suite does not imply certificate export
priyankatiwari08 5749b23
Adapt Slice D tests to Slice A review follow-up conventions
priyankatiwari08 121d8c0
Adapt Slice D native SNI capture to EncryptionInfoAccumulator
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
95 changes: 95 additions & 0 deletions
95
src/Microsoft.Data.SqlClient/src/Interop/Windows/Sni/SniCertValidationInfo.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,95 @@ | ||
| // 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; | ||
| using System.Runtime.InteropServices; | ||
|
|
||
| namespace Interop.Windows.Sni | ||
| { | ||
| /// <summary> | ||
| /// Managed mirror of the native <c>SNI_CERT_VALIDATION_INFO</c> structure filled by | ||
| /// <c>SNIGetCertValidationInfoWrapper</c>. Version 1 is 32 bytes of sequential, blittable | ||
| /// <c>DWORD</c> fields. | ||
| /// </summary> | ||
| /// <remarks> | ||
| /// A field is meaningful only when its corresponding <see cref="SniCertInfoAvailability"/> flag is | ||
| /// set in <see cref="dwAvailable"/>. The presented certificate itself is not part of this | ||
| /// structure; when <see cref="SniCertInfoAvailability.Certificate"/> is set it is read with | ||
| /// <c>SNIGetServerCertificateWrapper</c>. Earlier preview SNI libraries used a larger structure | ||
| /// and reject a <see cref="cbSize"/> of 32 with <c>ERROR_INVALID_PARAMETER</c>, so no data is | ||
| /// read from them. | ||
| /// </remarks> | ||
| [StructLayout(LayoutKind.Sequential)] | ||
| internal struct SniCertValidationInfo | ||
| { | ||
| /// <summary>Size, in bytes, of the structure requested by this client.</summary> | ||
| internal const int Size = 32; | ||
|
|
||
| /// <summary>Minimum structure version understood by this client.</summary> | ||
| internal const uint CurrentVersion = 1; | ||
|
|
||
| /// <summary>In: size of the caller's buffer (at least <see cref="Size"/>). Out: number of bytes written.</summary> | ||
| public uint cbSize; | ||
|
|
||
| /// <summary>Out: structure version.</summary> | ||
| public uint dwVersion; | ||
|
|
||
| /// <summary>Out: <see cref="SniCertInfoAvailability"/> flags.</summary> | ||
| public uint dwAvailable; | ||
|
|
||
| /// <summary>Out: <see cref="SniCertValidationMode"/> value.</summary> | ||
| public uint dwValidationMode; | ||
|
|
||
| /// <summary>Out: negotiated <c>SP_PROT_*</c> protocol bits.</summary> | ||
| public uint dwProtocol; | ||
|
|
||
| /// <summary>Out: effective validation error bits; identical to <c>SqlServerCertificateValidationErrors</c>.</summary> | ||
| public uint dwValidationErrors; | ||
|
|
||
| /// <summary>Out: raw <c>CERT_TRUST_STATUS.dwErrorStatus</c>; identical to <c>X509ChainStatusFlags</c>.</summary> | ||
| public uint dwChainStatus; | ||
|
|
||
| /// <summary>Out: IANA identifier of the negotiated TLS cipher suite.</summary> | ||
| public uint dwCipherSuite; | ||
|
|
||
| /// <summary> | ||
| /// Creates an instance ready to be passed to native code, with <see cref="cbSize"/> set. | ||
| /// </summary> | ||
| internal static SniCertValidationInfo Create() => new SniCertValidationInfo { cbSize = Size }; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Availability flags reported in <see cref="SniCertValidationInfo.dwAvailable"/>. | ||
| /// </summary> | ||
| [Flags] | ||
| internal enum SniCertInfoAvailability : uint | ||
| { | ||
| None = 0x0, | ||
| AttemptStarted = 0x1, | ||
| Protocol = 0x2, | ||
| Certificate = 0x4, | ||
| ValidationErrors = 0x8, | ||
| ChainStatus = 0x10, | ||
| HandshakeCompleted = 0x20, | ||
|
|
||
| /// <summary> | ||
| /// <see cref="SniCertValidationInfo.dwChainStatus"/> reflects only a leaf validity-period check | ||
| /// for a pinned certificate; no chain was built, so the chain status is not reported. | ||
| /// </summary> | ||
| ChainStatusLeafTimeOnly = 0x40, | ||
| CipherSuite = 0x80, | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Validation mode reported in <see cref="SniCertValidationInfo.dwValidationMode"/>. | ||
| /// </summary> | ||
| internal enum SniCertValidationMode : uint | ||
| { | ||
| Unknown = 0, | ||
| NotValidated = 1, | ||
| SchannelAutomatic = 2, | ||
| ChainPolicy = 3, | ||
| PinnedCertificate = 4, | ||
| } | ||
| } | ||
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
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
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.