-
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
Enable server-side OCSP stapling on Linux #69833
Conversation
Tagging subscribers to this area: @dotnet/ncl, @vcsjones Issue DetailsA few code reorganization notes:
With this change, Contexts that live for a long time and see regular activity should always have a response
|
src/libraries/System.Net.Security/src/System/Net/Security/SslStreamCertificateContext.Linux.cs
Show resolved
Hide resolved
src/libraries/System.Net.Security/src/System/Net/Security/SslStreamCertificateContext.cs
Outdated
Show resolved
Hide resolved
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.
generally looks good to me.
We seems to fail the build on some configurations.
Quic failures are known and unrelated.
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.
LGTM
Looks like there's some build configuration where time_t is |
((IDisposable)responseMessage).Dispose(); | ||
|
||
redirections++; | ||
if (redirections > MaxRedirections) |
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 don't remember why we do all this custom redirect handling rather than using the built-in support. Do you?
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.
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.
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.
@stephentoub are you suggesting in .NET 7.0?
I think we might be able to make it happen. Let's bring it up in next meeting.
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.
are you suggesting in .NET 7.0?
If we have time.
|
||
namespace System.Text | ||
{ | ||
internal static class Base64UrlEncoding |
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.
We've had multiple requests for this functionality, e.g. #1658. How close is this to what's needed for that? I'm wondering if we should use this as an opportunity to get it into the right shape and move that issue to api-ready-for-review so we can get it out in 7.
|
||
if (!_staplingForbidden) | ||
{ | ||
// Create the task, let the download finish in the background. |
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.
Can you elaborate on why it's ok for this to be fire-and-forget?
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.
Consistent with other platforms, the server side of OCSP stapling is bestish effortish. On Windows they equivalently fire off an async download, and whenever there's a new session and the download has completed they attach it... if it didn't complete (or it failed), then it isn't.
if (task.IsCompletedSuccessfully) | ||
{ | ||
return task.Result; | ||
} |
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.
Same here... why is it ok that this is fire-and-forget?
src/libraries/System.Net.Security/src/System/Net/Security/SslStreamCertificateContext.Linux.cs
Outdated
Show resolved
Hide resolved
{ | ||
Task<byte[]?>? pending = _pendingDownload; | ||
|
||
if (pending is not null && !pending.IsFaulted) |
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 never needs to transition from non-null back to null?
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.
_pendingDownload
goes back to null if it completes successfully. On... line.... that got deleted.
{ | ||
pending = _pendingDownload; | ||
|
||
if (pending is null || pending.IsFaulted) |
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.
If it's faulted, will someone somewhere have accessed its Exception or otherwise observed what the error was?
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.
Nope. If it faulted (most likely due to a timeout or network error) we'll just let another one spin up.
A few code reorganization notes:
With this change,
SslStreamCertificateContext.Create
on Linux will do a backgroundfetch of an OCSP response to staple to the Server Certificate in the Server Hello
portion of the handshake. This fetch is skipped if the context is built with offline:true.
Contexts that live for a long time and see regular activity should always have a response
ready to deliver to clients that ask for one. Particularly idle contexts that are retrieving
OCSP responses that have particularly short lifetimes may stop stapling because they may end up
not getting the activity they need to initiate a new request before the current response expires.
Contributes to #33377.