-
Notifications
You must be signed in to change notification settings - Fork 0
Code Review Bench PR #64970 - Ensure SSL_CERT_DIR messages are always shown and check for existing value #3
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
base: base_pr_64970_20260125_1452
Are you sure you want to change the base?
Changes from all commits
fade7c7
60be2ab
9fd206b
35584d7
c8ce09d
07d6e09
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -355,14 +355,57 @@ protected override TrustLevel TrustCertificateCore(X509Certificate2 certificate) | |||||
| ? Path.Combine("$HOME", certDir[homeDirectoryWithSlash.Length..]) | ||||||
| : certDir; | ||||||
|
|
||||||
| if (TryGetOpenSslDirectory(out var openSslDir)) | ||||||
| var hasValidSslCertDir = false; | ||||||
|
|
||||||
| // Check if SSL_CERT_DIR is already set and if certDir is already included | ||||||
| var existingSslCertDir = Environment.GetEnvironmentVariable(OpenSslCertificateDirectoryVariableName); | ||||||
| if (!string.IsNullOrEmpty(existingSslCertDir)) | ||||||
| { | ||||||
| var existingDirs = existingSslCertDir.Split(Path.PathSeparator); | ||||||
| var certDirFullPath = Path.GetFullPath(prettyCertDir); | ||||||
| var isCertDirIncluded = existingDirs.Any(dir => | ||||||
| { | ||||||
| if (string.IsNullOrWhiteSpace(dir)) | ||||||
| { | ||||||
| return false; | ||||||
| } | ||||||
|
|
||||||
| try | ||||||
| { | ||||||
| return string.Equals(Path.GetFullPath(dir), certDirFullPath, StringComparison.OrdinalIgnoreCase); | ||||||
|
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.
|
||||||
| return string.Equals(Path.GetFullPath(dir), certDirFullPath, StringComparison.OrdinalIgnoreCase); | |
| return string.Equals(Path.GetFullPath(dir), certDirFullPath, StringComparison.Ordinal); |
- Apply suggested fix
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.
⚠️ Bug: sawTrustFailure overwrite can mask prior NSS DB trust failures
Line 408 unconditionally assigns sawTrustFailure = !hasValidSslCertDir, which can overwrite a previous true value set by NSS DB trust failures (lines 295, 322, 328).
Scenario: NSS DB trust fails (sawTrustFailure = true), but OpenSSL trust succeeds and SSL_CERT_DIR is correctly configured (hasValidSslCertDir = true). The assignment sawTrustFailure = false masks the NSS failure, and the method returns TrustLevel.Full instead of TrustLevel.Partial.
Fix: Use |= to accumulate failures rather than overwrite:
sawTrustFailure |= !hasValidSslCertDir;This ensures that if any prior trust step failed, the overall result still reflects partial trust.
Was this helpful? React with 👍 / 👎
| sawTrustFailure = !hasValidSslCertDir; | |
| sawTrustFailure |= !hasValidSslCertDir; |
- Apply suggested fix
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.
🚨 Bug:
Path.GetFullPath(prettyCertDir)breaks when path contains literal$HOMEWhen
certDirstarts with the home directory,prettyCertDiris set to a display-friendly string like$HOME/.aspnet/dev-certs/trust(line 354-356). Then on line 365,Path.GetFullPath(prettyCertDir)is called on this value.Path.GetFullPathdoes NOT expand shell variables —$HOMEis treated as a literal directory name. On Unix, this resolves to something like/current/working/dir/$HOME/.aspnet/dev-certs/trust, which will never match any real path inSSL_CERT_DIR.This means the certificate directory inclusion check will always fail for users whose cert dir is under their home directory (the common case), causing spurious "suggest appending" messages even when
SSL_CERT_DIRis already correctly configured.Fix: Use
certDir(the actual filesystem path) instead ofprettyCertDirfor thePath.GetFullPathcall:prettyCertDirshould only be used for display/logging purposes, not for path resolution.Was this helpful? React with 👍 / 👎