Skip to content

Commit a9f0e34

Browse files
committed
Add descriptive text
1 parent 58e5073 commit a9f0e34

File tree

3 files changed

+35
-15
lines changed

3 files changed

+35
-15
lines changed

src/Shared/CertificateGeneration/CertificateManager.cs

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -178,22 +178,24 @@ public EnsureCertificateResult EnsureAspNetCoreHttpsDevelopmentCertificate(
178178
{
179179
// Skip this step if the command is not interactive,
180180
// as we don't want to prompt on first run experience.
181-
// Check only the first certificate as is the one we plan to use.
182-
var status = CheckCertificateState(certificate, true);
183-
if (!status.Result)
181+
foreach (var candidate in certificates)
184182
{
185-
try
183+
var status = CheckCertificateState(candidate, true);
184+
if (!status.Result)
186185
{
187-
Log.CorrectCertificateStateStart(CertificateManagerEventSource.GetDescription(certificate));
188-
CorrectCertificateState(certificate);
189-
Log.CorrectCertificateStateEnd();
190-
}
191-
catch (Exception e)
192-
{
193-
Log.CorrectCertificateStateError(e.ToString());
194-
result = EnsureCertificateResult.FailedToMakeKeyAccessible;
195-
return result;
196-
}
186+
try
187+
{
188+
Log.CorrectCertificateStateStart(CertificateManagerEventSource.GetDescription(candidate));
189+
CorrectCertificateState(candidate);
190+
Log.CorrectCertificateStateEnd();
191+
}
192+
catch (Exception e)
193+
{
194+
Log.CorrectCertificateStateError(e.ToString());
195+
result = EnsureCertificateResult.FailedToMakeKeyAccessible;
196+
return result;
197+
}
198+
}
197199
}
198200
}
199201
else

src/Shared/CertificateGeneration/MacOSCertificateManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ internal class MacOSCertificateManager : CertificateManager
3232
public const string KeyNotAccessibleWithoutUserInteraction =
3333
"Kestrel is trying to access the ASP.NET Core developer certificate key. " +
3434
"A prompt might appear to ask for permission to access the key. " +
35-
"When that happens, select 'Always allow' to grant 'dotnet' access to the certificate key in the future.";
35+
"When that happens, select 'Always Allow' to grant 'dotnet' access to the certificate key in the future.";
3636

3737
private static readonly TimeSpan MaxRegexTimeout = TimeSpan.FromMinutes(1);
3838

src/Tools/dotnet-dev-certs/src/Program.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,24 @@ private static int EnsureHttpsCertificate(CommandOption exportPath, CommandOptio
209209
var now = DateTimeOffset.Now;
210210
var manager = CertificateManager.Instance;
211211

212+
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
213+
{
214+
var certificates = manager.ListCertificates(StoreName.My, StoreLocation.CurrentUser, isValid: true, exportPath.HasValue());
215+
foreach (var certificate in certificates)
216+
{
217+
var status = manager.CheckCertificateState(certificate, interactive: true);
218+
if (!status.Result)
219+
{
220+
reporter.Warn("One or more certificates might be in an invalid state. We will try to access the certificate key " +
221+
"for each certificate and as a result you might be prompted one or more times to enter " +
222+
"your password to access the user keychain. " +
223+
"When that happens, select 'Always Allow' to grant 'dotnet' access to the certificate key in the future.");
224+
}
225+
226+
break;
227+
}
228+
}
229+
212230
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX) && trust?.HasValue() == true)
213231
{
214232
reporter.Warn("Trusting the HTTPS development certificate was requested. If the certificate is not " +

0 commit comments

Comments
 (0)