Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Use certificate thumbprints from entire chain in SSL_CTX cache #112858

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

Conversation

rzikm
Copy link
Member

@rzikm rzikm commented Feb 24, 2025

Fixes #112856.

Update the SSL context cache to utilize certificate thumbprints from the entire certificate chain. This mimics what we do for MsQuic

private readonly struct CacheKey : IEquatable<CacheKey>

@Copilot Copilot AI review requested due to automatic review settings February 24, 2025 13:15
@rzikm rzikm requested a review from wfurt February 24, 2025 13:16
@rzikm
Copy link
Member Author

rzikm commented Feb 24, 2025

/azp run runtime-libraries-coreclr outerloop

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

@@ -36,33 +36,62 @@ private sealed class SafeSslContextCache : SafeHandleCache<SslContextCacheKey, S
internal readonly struct SslContextCacheKey : IEquatable<SslContextCacheKey>
{
public readonly bool IsClient;
public readonly byte[]? CertificateThumbprint;
public readonly List<byte[]> CertificateThumbprints;
Copy link
Preview

Copilot AI Feb 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The CertificateThumbprints field is declared as a public readonly List, but the list itself remains mutable. This can lead to unexpected behavior when this key is used in caching or dictionary operations, so consider exposing an immutable collection or making a defensive copy in the constructor.

Suggested change
public readonly List<byte[]> CertificateThumbprints;
public readonly ReadOnlyCollection<byte[]> CertificateThumbprints;

Copilot uses AI. Check for mistakes.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it seems like simple array would be sufficient as we know the count upfront...

Copy link
Member

@wfurt wfurt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@rzikm
Copy link
Member Author

rzikm commented Feb 24, 2025

/azp run runtime-libraries-coreclr outerloop

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@ShreyasJejurkar
Copy link
Contributor

Nice branch name 😅😅

@rzikm
Copy link
Member Author

rzikm commented Feb 25, 2025

/ba-g No failures in System.Net.* namespace, rest of the failures should be unrelated

@rzikm rzikm merged commit d343214 into dotnet:main Feb 25, 2025
78 of 91 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Mar 28, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
3 participants