-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
add support of TLS 1.3 on macOS POC #104835
Draft
wfurt
wants to merge
35
commits into
dotnet:main
Choose a base branch
from
wfurt:macNw
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 30 commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
f5d116d
snap
wfurt c3be4f3
tests
wfurt 86665f6
snap
wfurt 7c3e67b
snap
wfurt 02c1eb3
snap
wfurt 11edad8
snap
wfurt fcc9879
snap
wfurt 7361d26
snap
wfurt 53b69f6
snap
wfurt 093d9bb
Merge branch 'main' of https://github.com/dotnet/runtime into macNw
wfurt 83901ca
update
wfurt 3ca7fbc
update
wfurt d07c7b9
build update
wfurt ad8fadf
build
wfurt 637524d
alpn
wfurt 64077b5
build
wfurt a8a7bed
build
wfurt e0b6d0c
update
wfurt b2dc3be
Merge branch 'main' of https://github.com/dotnet/runtime into macNw
wfurt 95e0c33
Merge branch 'main' of https://github.com/dotnet/runtime into macNw
wfurt 89c0444
Merge branch 'main' of https://github.com/dotnet/runtime into macNw
wfurt 7fec8ae
build
wfurt b8b64d0
Merge branch 'main' of https://github.com/dotnet/runtime into macNw
wfurt 9d5b512
Merge branch 'macNw' of https://github.com/wfurt/runtime into macNw
wfurt 97f59d2
aot
wfurt b643236
builder
wfurt 40f31e1
Merge branch 'macNw' of https://github.com/wfurt/runtime into macNw
wfurt 10138f9
Merge branch 'main' of https://github.com/dotnet/runtime into macNw
wfurt 082cf40
update
wfurt 79be6bc
Merge branch 'main' of https://github.com/dotnet/runtime into macNw
wfurt cb8e52b
Merge branch 'main' of https://github.com/dotnet/runtime into macNw
wfurt 5f4caaf
Merge branch 'main' into macNw
liveans ea06c41
Review feedback before refactoring around SafeDeleteSslContext and In…
liveans ed492ff
Indentation
liveans 30c744e
Fix Net48 build
liveans 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 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 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 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 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 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 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 |
---|---|---|
|
@@ -30,7 +30,7 @@ internal static SslPolicyErrors VerifyCertificateProperties( | |
errors |= SslPolicyErrors.RemoteCertificateChainErrors; | ||
} | ||
|
||
if (!isServer && checkCertName) | ||
if (!isServer && checkCertName && ! (((SafeDeleteSslContext)securityContext).UseNwFramework)) | ||
{ | ||
SafeDeleteSslContext sslContext = (SafeDeleteSslContext)securityContext; | ||
|
||
|
@@ -67,9 +67,11 @@ internal static SslPolicyErrors VerifyCertificateProperties( | |
|
||
X509Certificate2? result = null; | ||
|
||
using (SafeX509ChainHandle chainHandle = Interop.AppleCrypto.SslCopyCertChain(sslContext)) | ||
if (((SafeDeleteSslContext)securityContext).UseNwFramework) | ||
{ | ||
long chainSize = Interop.AppleCrypto.X509ChainGetChainSize(chainHandle); | ||
SafeCFArrayHandle certificates; | ||
|
||
Interop.AppleCrypto.NwCopyCertChain(sslContext, out certificates, out int chainSize); | ||
|
||
if (retrieveChainCertificates && chainSize > 1) | ||
{ | ||
|
@@ -83,7 +85,7 @@ internal static SslPolicyErrors VerifyCertificateProperties( | |
// Any any additional intermediate CAs to ExtraStore. | ||
for (int i = 1; i < chainSize; i++) | ||
{ | ||
IntPtr certHandle = Interop.AppleCrypto.X509ChainGetCertificateAtIndex(chainHandle, i); | ||
IntPtr certHandle = Interop.CoreFoundation.CFArrayGetValueAtIndex(certificates, i); | ||
chain.ChainPolicy.ExtraStore.Add(new X509Certificate2(certHandle)); | ||
} | ||
} | ||
|
@@ -92,10 +94,42 @@ internal static SslPolicyErrors VerifyCertificateProperties( | |
// to match what the Windows and Unix PALs do. | ||
if (chainSize > 0) | ||
{ | ||
IntPtr certHandle = Interop.AppleCrypto.X509ChainGetCertificateAtIndex(chainHandle, 0); | ||
IntPtr certHandle = Interop.CoreFoundation.CFArrayGetValueAtIndex(certificates, 0); | ||
result = new X509Certificate2(certHandle); | ||
} | ||
} | ||
else | ||
{ | ||
using (SafeX509ChainHandle chainHandle = Interop.AppleCrypto.SslCopyCertChain(sslContext)) | ||
{ | ||
long chainSize = Interop.AppleCrypto.X509ChainGetChainSize(chainHandle); | ||
|
||
if (retrieveChainCertificates && chainSize > 1) | ||
{ | ||
chain ??= new X509Chain(); | ||
if (chainPolicy != null) | ||
{ | ||
chain.ChainPolicy = chainPolicy; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the chain was passed in, might this be overriding a policy that was already there? |
||
} | ||
|
||
// First certificate is peer's certificate. | ||
// Any any additional intermediate CAs to ExtraStore. | ||
for (int i = 1; i < chainSize; i++) | ||
{ | ||
IntPtr certHandle = Interop.AppleCrypto.X509ChainGetCertificateAtIndex(chainHandle, i); | ||
chain.ChainPolicy.ExtraStore.Add(new X509Certificate2(certHandle)); | ||
} | ||
} | ||
|
||
// This will be a distinct object than remoteCertificateStore[0] (if applicable), | ||
// to match what the Windows and Unix PALs do. | ||
if (chainSize > 0) | ||
{ | ||
IntPtr certHandle = Interop.AppleCrypto.X509ChainGetCertificateAtIndex(chainHandle, 0); | ||
result = new X509Certificate2(certHandle); | ||
} | ||
} | ||
} | ||
|
||
if (NetEventSource.Log.IsEnabled()) NetEventSource.Log.RemoteCertificate(result); | ||
|
||
|
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume Nw* and Ssl* functions can't be used interchangeably, would it make sense to move it to its own class like
Interop.NetworkFramework
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would be helpful, especially for the possible future implementations/experiments. (QUIC API is there and can be used with couple of more interop additions to this. (there are some bugs))