Skip to content

Commit 6ae6f65

Browse files
committed
Log dotnet trust success
1 parent 48da760 commit 6ae6f65

File tree

2 files changed

+52
-48
lines changed

2 files changed

+52
-48
lines changed

src/Shared/CertificateGeneration/CertificateManager.cs

Lines changed: 51 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1135,83 +1135,86 @@ public sealed class CertificateManagerEventSource : EventSource
11351135
[Event(86, Level = EventLevel.Warning, Message = "Failed to trust the certificate in .NET: {0}.")]
11361136
internal void UnixDotnetTrustException(string exceptionMessage) => WriteEvent(86, exceptionMessage);
11371137

1138-
[Event(87, Level = EventLevel.Warning, Message = "Clients that validate certificate trust using OpenSSL will not trust the certificate.")]
1139-
internal void UnixOpenSslTrustFailed() => WriteEvent(87);
1138+
[Event(87, Level = EventLevel.Verbose, Message = "Trusted the certificate in .NET.")]
1139+
internal void UnixDotnetTrustSucceeded() => WriteEvent(87);
11401140

1141-
[Event(88, Level = EventLevel.Verbose, Message = "Trusted the certificate in OpenSSL.")]
1142-
internal void UnixOpenSslTrustSucceeded() => WriteEvent(88);
1141+
[Event(88, Level = EventLevel.Warning, Message = "Clients that validate certificate trust using OpenSSL will not trust the certificate.")]
1142+
internal void UnixOpenSslTrustFailed() => WriteEvent(88);
11431143

1144-
[Event(89, Level = EventLevel.Warning, Message = "Failed to trust the certificate in the NSS database in '{0}'. This will likely affect the {1} family of browsers.")]
1145-
internal void UnixNssDbTrustFailed(string path, string browser) => WriteEvent(89, path, browser);
1144+
[Event(89, Level = EventLevel.Verbose, Message = "Trusted the certificate in OpenSSL.")]
1145+
internal void UnixOpenSslTrustSucceeded() => WriteEvent(89);
11461146

1147-
[Event(90, Level = EventLevel.Verbose, Message = "Trusted the certificate in the NSS database in '{0}'.")]
1148-
internal void UnixNssDbTrustSucceeded(string path) => WriteEvent(90, path);
1147+
[Event(90, Level = EventLevel.Warning, Message = "Failed to trust the certificate in the NSS database in '{0}'. This will likely affect the {1} family of browsers.")]
1148+
internal void UnixNssDbTrustFailed(string path, string browser) => WriteEvent(90, path, browser);
11491149

1150-
[Event(91, Level = EventLevel.Warning, Message = "Failed to untrust the certificate in .NET: {0}.")]
1151-
internal void UnixDotnetUntrustException(string exceptionMessage) => WriteEvent(91, exceptionMessage);
1150+
[Event(91, Level = EventLevel.Verbose, Message = "Trusted the certificate in the NSS database in '{0}'.")]
1151+
internal void UnixNssDbTrustSucceeded(string path) => WriteEvent(91, path);
11521152

1153-
[Event(92, Level = EventLevel.Warning, Message = "Failed to untrust the certificate in OpenSSL.")]
1154-
internal void UnixOpenSslUntrustFailed() => WriteEvent(92);
1153+
[Event(92, Level = EventLevel.Warning, Message = "Failed to untrust the certificate in .NET: {0}.")]
1154+
internal void UnixDotnetUntrustException(string exceptionMessage) => WriteEvent(92, exceptionMessage);
11551155

1156-
[Event(93, Level = EventLevel.Verbose, Message = "Untrusted the certificate in OpenSSL.")]
1157-
internal void UnixOpenSslUntrustSucceeded() => WriteEvent(93);
1156+
[Event(93, Level = EventLevel.Warning, Message = "Failed to untrust the certificate in OpenSSL.")]
1157+
internal void UnixOpenSslUntrustFailed() => WriteEvent(93);
11581158

1159-
[Event(94, Level = EventLevel.Warning, Message = "Failed to remove the certificate from the NSS database in '{0}'.")]
1160-
internal void UnixNssDbUntrustFailed(string path) => WriteEvent(94, path);
1159+
[Event(94, Level = EventLevel.Verbose, Message = "Untrusted the certificate in OpenSSL.")]
1160+
internal void UnixOpenSslUntrustSucceeded() => WriteEvent(94);
11611161

1162-
[Event(95, Level = EventLevel.Verbose, Message = "Removed the certificate from the NSS database in '{0}'.")]
1163-
internal void UnixNssDbUntrustSucceeded(string path) => WriteEvent(95, path);
1162+
[Event(95, Level = EventLevel.Warning, Message = "Failed to remove the certificate from the NSS database in '{0}'.")]
1163+
internal void UnixNssDbUntrustFailed(string path) => WriteEvent(95, path);
11641164

1165-
[Event(96, Level = EventLevel.Warning, Message = "The certificate is only partially trusted - some clients will not accept it.")]
1166-
internal void UnixTrustPartiallySucceeded() => WriteEvent(96);
1165+
[Event(96, Level = EventLevel.Verbose, Message = "Removed the certificate from the NSS database in '{0}'.")]
1166+
internal void UnixNssDbUntrustSucceeded(string path) => WriteEvent(96, path);
11671167

1168-
[Event(97, Level = EventLevel.Warning, Message = "Failed to look up the certificate in the NSS database in '{0}': {1}.")]
1169-
internal void UnixNssDbCheckException(string path, string exceptionMessage) => WriteEvent(97, path, exceptionMessage);
1168+
[Event(97, Level = EventLevel.Warning, Message = "The certificate is only partially trusted - some clients will not accept it.")]
1169+
internal void UnixTrustPartiallySucceeded() => WriteEvent(97);
11701170

1171-
[Event(98, Level = EventLevel.Warning, Message = "Failed to add the certificate to the NSS database in '{0}': {1}.")]
1172-
internal void UnixNssDbAdditionException(string path, string exceptionMessage) => WriteEvent(98, path, exceptionMessage);
1171+
[Event(98, Level = EventLevel.Warning, Message = "Failed to look up the certificate in the NSS database in '{0}': {1}.")]
1172+
internal void UnixNssDbCheckException(string path, string exceptionMessage) => WriteEvent(98, path, exceptionMessage);
11731173

1174-
[Event(99, Level = EventLevel.Warning, Message = "Failed to remove the certificate from the NSS database in '{0}': {1}.")]
1175-
internal void UnixNssDbRemovalException(string path, string exceptionMessage) => WriteEvent(99, path, exceptionMessage);
1174+
[Event(99, Level = EventLevel.Warning, Message = "Failed to add the certificate to the NSS database in '{0}': {1}.")]
1175+
internal void UnixNssDbAdditionException(string path, string exceptionMessage) => WriteEvent(99, path, exceptionMessage);
11761176

1177-
[Event(100, Level = EventLevel.Warning, Message = "Failed to find the Firefox profiles in directory '{0}': {1}.")]
1178-
internal void UnixFirefoxProfileEnumerationException(string firefoxDirectory, string message) => WriteEvent(100, firefoxDirectory, message);
1177+
[Event(100, Level = EventLevel.Warning, Message = "Failed to remove the certificate from the NSS database in '{0}': {1}.")]
1178+
internal void UnixNssDbRemovalException(string path, string exceptionMessage) => WriteEvent(100, path, exceptionMessage);
11791179

1180-
[Event(101, Level = EventLevel.Verbose, Message = "No Firefox profiles found in directory '{0}'.")]
1181-
internal void UnixNoFirefoxProfilesFound(string firefoxDirectory) => WriteEvent(101, firefoxDirectory);
1180+
[Event(101, Level = EventLevel.Warning, Message = "Failed to find the Firefox profiles in directory '{0}': {1}.")]
1181+
internal void UnixFirefoxProfileEnumerationException(string firefoxDirectory, string message) => WriteEvent(101, firefoxDirectory, message);
11821182

1183-
[Event(102, Level = EventLevel.Warning, Message = "Failed to trust the certificate in the NSS database in '{0}'. This will likely affect the {1} family of browsers. " +
1183+
[Event(102, Level = EventLevel.Verbose, Message = "No Firefox profiles found in directory '{0}'.")]
1184+
internal void UnixNoFirefoxProfilesFound(string firefoxDirectory) => WriteEvent(102, firefoxDirectory);
1185+
1186+
[Event(103, Level = EventLevel.Warning, Message = "Failed to trust the certificate in the NSS database in '{0}'. This will likely affect the {1} family of browsers. " +
11841187
"This likely indicates that the database already contains an entry for the certificate under a different name. Please remove it and try again.")]
1185-
internal void UnixNssDbTrustFailedWithProbableConflict(string path, string browser) => WriteEvent(102, path, browser);
1188+
internal void UnixNssDbTrustFailedWithProbableConflict(string path, string browser) => WriteEvent(103, path, browser);
11861189

11871190
// This may be annoying, since anyone setting the variable for un/trust will likely leave it set for --check.
11881191
// However, it seems important to warn users who set it specifically for --check.
1189-
[Event(103, Level = EventLevel.Warning, Message = "The {0} environment variable is set but will not be consumed while checking trust.")]
1190-
internal void UnixOpenSslCertificateDirectoryOverrideIgnored(string openSslCertDirectoryOverrideVariableName) => WriteEvent(103, openSslCertDirectoryOverrideVariableName);
1192+
[Event(104, Level = EventLevel.Warning, Message = "The {0} environment variable is set but will not be consumed while checking trust.")]
1193+
internal void UnixOpenSslCertificateDirectoryOverrideIgnored(string openSslCertDirectoryOverrideVariableName) => WriteEvent(104, openSslCertDirectoryOverrideVariableName);
11911194

1192-
[Event(104, Level = EventLevel.Warning, Message = "The {0} command is unavailable. It is required for updating certificate trust in OpenSSL.")]
1193-
internal void UnixMissingOpenSslCommand(string openSslCommand) => WriteEvent(104, openSslCommand);
1195+
[Event(105, Level = EventLevel.Warning, Message = "The {0} command is unavailable. It is required for updating certificate trust in OpenSSL.")]
1196+
internal void UnixMissingOpenSslCommand(string openSslCommand) => WriteEvent(105, openSslCommand);
11941197

1195-
[Event(105, Level = EventLevel.Warning, Message = "The {0} command is unavailable. It is required for querying and updating NSS databases, which are chiefly used to trust certificates in browsers.")]
1196-
internal void UnixMissingCertUtilCommand(string certUtilCommand) => WriteEvent(105, certUtilCommand);
1198+
[Event(106, Level = EventLevel.Warning, Message = "The {0} command is unavailable. It is required for querying and updating NSS databases, which are chiefly used to trust certificates in browsers.")]
1199+
internal void UnixMissingCertUtilCommand(string certUtilCommand) => WriteEvent(106, certUtilCommand);
11971200

1198-
[Event(106, Level = EventLevel.Verbose, Message = "Untrusting the certificate in OpenSSL was skipped since '{0}' does not exist.")]
1199-
internal void UnixOpenSslUntrustSkipped(string certPath) => WriteEvent(106, certPath);
1201+
[Event(107, Level = EventLevel.Verbose, Message = "Untrusting the certificate in OpenSSL was skipped since '{0}' does not exist.")]
1202+
internal void UnixOpenSslUntrustSkipped(string certPath) => WriteEvent(107, certPath);
12001203

1201-
[Event(107, Level = EventLevel.Warning, Message = "Failed to delete certificate file '{0}': {1}.")]
1202-
internal void UnixCertificateFileDeletionException(string certPath, string exceptionMessage) => WriteEvent(107, certPath, exceptionMessage);
1204+
[Event(108, Level = EventLevel.Warning, Message = "Failed to delete certificate file '{0}': {1}.")]
1205+
internal void UnixCertificateFileDeletionException(string certPath, string exceptionMessage) => WriteEvent(108, certPath, exceptionMessage);
12031206

1204-
[Event(108, Level = EventLevel.Error, Message = "Unable to export the certificate since '{0}' already exists. Please remove it.")]
1205-
internal void UnixNotOverwritingCertificate(string certPath) => WriteEvent(108, certPath);
1207+
[Event(109, Level = EventLevel.Error, Message = "Unable to export the certificate since '{0}' already exists. Please remove it.")]
1208+
internal void UnixNotOverwritingCertificate(string certPath) => WriteEvent(109, certPath);
12061209

1207-
[Event(109, Level = EventLevel.LogAlways, Message = "For OpenSSL trust to take effect, '{0}' must be listed in the {2} environment variable. " +
1210+
[Event(110, Level = EventLevel.LogAlways, Message = "For OpenSSL trust to take effect, '{0}' must be listed in the {2} environment variable. " +
12081211
"For example, `export SSL_CERT_DIR={0}:{1}`. " +
12091212
"See https://aka.ms/dev-certs-trust for more information.")]
1210-
internal void UnixSuggestSettingEnvironmentVariable(string certDir, string openSslDir, string envVarName) => WriteEvent(109, certDir, openSslDir, envVarName);
1213+
internal void UnixSuggestSettingEnvironmentVariable(string certDir, string openSslDir, string envVarName) => WriteEvent(110, certDir, openSslDir, envVarName);
12111214

1212-
[Event(110, Level = EventLevel.LogAlways, Message = "For OpenSSL trust to take effect, '{0}' must be listed in the {2} environment variable. " +
1215+
[Event(111, Level = EventLevel.LogAlways, Message = "For OpenSSL trust to take effect, '{0}' must be listed in the {2} environment variable. " +
12131216
"See https://aka.ms/dev-certs-trust for more information.")]
1214-
internal void UnixSuggestSettingEnvironmentVariableWithoutExample(string certDir, string envVarName) => WriteEvent(110, certDir, envVarName);
1217+
internal void UnixSuggestSettingEnvironmentVariableWithoutExample(string certDir, string envVarName) => WriteEvent(111, certDir, envVarName);
12151218
}
12161219

12171220
internal sealed class UserCancelledTrustException : Exception

src/Shared/CertificateGeneration/UnixCertificateManager.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ protected override TrustLevel TrustCertificateCore(X509Certificate2 certificate)
196196
using var publicCertificate = X509CertificateLoader.LoadCertificate(certificate.Export(X509ContentType.Cert));
197197
// FriendlyName is Windows-only, so we don't set it here.
198198
store.Add(publicCertificate);
199+
Log.UnixDotnetTrustSucceeded();
199200
sawTrustSuccess = true;
200201
}
201202
catch (Exception ex)

0 commit comments

Comments
 (0)