-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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 tracing to the Linux X509Chain implementation #65860
Conversation
Tagging subscribers to this area: @dotnet/area-system-security, @vcsjones Issue DetailsThe tracing is heavily focused on transient behaviors, like AIA/CRL/OCSP downloads and cache interactions. Things like applying ApplicationPolicy aren't really traced because that can be "easily" evaluated by looking at the certificates in isolation. Example tracing, from the microsoft.com certificate:
Fixes #40445.
|
...raphy/src/System/Security/Cryptography/X509Certificates/OpenSslCertificateAssetDownloader.cs
Outdated
Show resolved
Hide resolved
...raphy/src/System/Security/Cryptography/X509Certificates/OpenSslCertificateAssetDownloader.cs
Show resolved
Hide resolved
...ryptography/src/System/Security/Cryptography/X509Certificates/OpenSslX509ChainEventSource.cs
Outdated
Show resolved
Hide resolved
} | ||
else | ||
{ | ||
OpenSslX509ChainEventSource.Log.NonHttpCdpEntry(name.Uri); |
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.
It might be "http" but failed to parse because of some issue later in the uri. Is that ok?
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.
PerfView would just see it as NonHttpCdpEntry / http://test..?q=w
.
Something that takes the message into account would see Skipping CDP entry 'http://test..?q=w' because the protocol is not HTTP.
, which seems less than ideal, but not too far off the mark.
internal bool ShouldLogElementStatuses() | ||
{ | ||
return IsEnabled(EventLevel.Verbose, EventKeywords.None); | ||
} |
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.
@marek-safar, will this helper confuse the linker and its ability to remove EventSource-related code based on guards, or is this ok?
} | ||
} | ||
|
||
OpenSslX509ChainEventSource.Log.NoMatchingCdpEntry(); |
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.
FWIW, we've typically guarded all EventSource calls, even parameterless onces, with IsEnabled() checks. Part of that has been historical, and part of that has been in support of the linker being able to remove everything that's only referenced inside such a guard. @marek-safar should comment on whether this is ok.
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.
And here I thought that was an artifact of older patterns.
So the correct style, for dotnet/runtime, at least, is an IsEnabled check on both the outside and the inside of the method? (I feel like EventSource's documentation said to have an IsEnabled check for each method, presumably to avoid things like creating the params array when it doesn't matter) Or do we do them outside-only?
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.
Yep, linker will have right now difficulties propagating this information. The best is to call directly methods that are substituted when event source is disabled
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.
Other than my comments, LGTM. I didn't analyze all of the reasons for each of the events; I'm assuming since you added them you believe they're all warranted and helpful.
The tracing is heavily focused on transient behaviors, like AIA/CRL/OCSP downloads and cache interactions.
Things like applying ApplicationPolicy aren't really traced because that can be "easily" evaluated by looking at the certificates in isolation.
Example tracing, from the microsoft.com certificate:
Fixes #40445.