-
Notifications
You must be signed in to change notification settings - Fork 0
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: copilot_full_base_ensure_ssl_cert_dir_messages_are_always_shown_and_check_for_existing_value_pr3
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); | ||||||
| } | ||||||
| catch | ||||||
| { | ||||||
| // Ignore invalid directory entries in SSL_CERT_DIR | ||||||
| return false; | ||||||
| } | ||||||
| }); | ||||||
|
|
||||||
| if (isCertDirIncluded) | ||||||
| { | ||||||
| // The certificate directory is already in SSL_CERT_DIR, no action needed | ||||||
| Log.UnixOpenSslCertificateDirectoryAlreadyConfigured(prettyCertDir, OpenSslCertificateDirectoryVariableName); | ||||||
| hasValidSslCertDir = true; | ||||||
| } | ||||||
| else | ||||||
| { | ||||||
| // SSL_CERT_DIR is set but doesn't include our directory - suggest appending | ||||||
| Log.UnixSuggestAppendingToEnvironmentVariable(prettyCertDir, OpenSslCertificateDirectoryVariableName); | ||||||
| hasValidSslCertDir = false; | ||||||
| } | ||||||
| } | ||||||
| else if (TryGetOpenSslDirectory(out var openSslDir)) | ||||||
| { | ||||||
| Log.UnixSuggestSettingEnvironmentVariable(prettyCertDir, Path.Combine(openSslDir, "certs"), OpenSslCertificateDirectoryVariableName); | ||||||
| hasValidSslCertDir = false; | ||||||
| } | ||||||
| else | ||||||
| { | ||||||
| Log.UnixSuggestSettingEnvironmentVariableWithoutExample(prettyCertDir, OpenSslCertificateDirectoryVariableName); | ||||||
| hasValidSslCertDir = false; | ||||||
| } | ||||||
|
|
||||||
| sawTrustFailure = !hasValidSslCertDir; | ||||||
|
||||||
| sawTrustFailure = !hasValidSslCertDir; | |
| sawTrustFailure |= !hasValidSslCertDir; |
Copilot
AI
Jan 25, 2026
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 change replaces a C# 12+ primary constructor with an explicit constructor and private fields. According to the coding guidelines, the repository uses C# 13 features (LangVersion is set to "preview" in eng/targets/CSharp.Common.props), and primary constructors are supported. The original primary constructor syntax private sealed class NssDb(string path, bool isFirefox) is more concise and idiomatic in modern C#. Unless there's a specific reason for this change (e.g., additional initialization logic needed), the primary constructor should be retained.
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.
Using
Path.GetFullPath(prettyCertDir)is incorrect becauseprettyCertDirmay contain$HOME(a shell variable placeholder for display purposes), not an actual path. WhencertDirstarts with the home directory, line 355 replaces it with$HOME, makingprettyCertDira display string like$HOME/.aspnet/dev-certs/trust. CallingPath.GetFullPath()on this will not work correctly as it doesn't expand shell variables.Instead, use
certDir(which is the actual full path) for comparison. The variableprettyCertDirshould only be used for display in log messages.