Skip to content

Commit 42a6608

Browse files
committed
Log dotnet trust success
1 parent dd1539d commit 42a6608

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
@@ -1131,83 +1131,86 @@ public sealed class CertificateManagerEventSource : EventSource
11311131
[Event(86, Level = EventLevel.Warning, Message = "Failed to trust the certificate in .NET: {0}.")]
11321132
internal void UnixDotnetTrustException(string exceptionMessage) => WriteEvent(86, exceptionMessage);
11331133

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

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

1140-
[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.")]
1141-
internal void UnixNssDbTrustFailed(string path, string browser) => WriteEvent(89, path, browser);
1140+
[Event(89, Level = EventLevel.Verbose, Message = "Trusted the certificate in OpenSSL.")]
1141+
internal void UnixOpenSslTrustSucceeded() => WriteEvent(89);
11421142

1143-
[Event(90, Level = EventLevel.Verbose, Message = "Trusted the certificate in the NSS database in '{0}'.")]
1144-
internal void UnixNssDbTrustSucceeded(string path) => WriteEvent(90, path);
1143+
[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.")]
1144+
internal void UnixNssDbTrustFailed(string path, string browser) => WriteEvent(90, path, browser);
11451145

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

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

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

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

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

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

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

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

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

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

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

1179-
[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. " +
1179+
[Event(102, Level = EventLevel.Verbose, Message = "No Firefox profiles found in directory '{0}'.")]
1180+
internal void UnixNoFirefoxProfilesFound(string firefoxDirectory) => WriteEvent(102, firefoxDirectory);
1181+
1182+
[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. " +
11801183
"This likely indicates that the database already contains an entry for the certificate under a different name. Please remove it and try again.")]
1181-
internal void UnixNssDbTrustFailedWithProbableConflict(string path, string browser) => WriteEvent(102, path, browser);
1184+
internal void UnixNssDbTrustFailedWithProbableConflict(string path, string browser) => WriteEvent(103, path, browser);
11821185

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

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

1191-
[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.")]
1192-
internal void UnixMissingCertUtilCommand(string certUtilCommand) => WriteEvent(105, certUtilCommand);
1194+
[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.")]
1195+
internal void UnixMissingCertUtilCommand(string certUtilCommand) => WriteEvent(106, certUtilCommand);
11931196

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

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

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

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

1208-
[Event(110, Level = EventLevel.LogAlways, Message = "For OpenSSL trust to take effect, '{0}' must be listed in the {2} environment variable. " +
1211+
[Event(111, Level = EventLevel.LogAlways, Message = "For OpenSSL trust to take effect, '{0}' must be listed in the {2} environment variable. " +
12091212
"See https://aka.ms/dev-certs-trust for more information.")]
1210-
internal void UnixSuggestSettingEnvironmentVariableWithoutExample(string certDir, string envVarName) => WriteEvent(110, certDir, envVarName);
1213+
internal void UnixSuggestSettingEnvironmentVariableWithoutExample(string certDir, string envVarName) => WriteEvent(111, certDir, envVarName);
12111214
}
12121215

12131216
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)