Skip to content

Commit

Permalink
Ensure certificate directory exists before creating it (#650)
Browse files Browse the repository at this point in the history
### Summary & Motivation

When running on Windows, the `dotnet dev-certs` command fails to create
the SSL certificate when the `.aspnet/dev-certs/https/` folder doesn't
exist.

This change ensures the full path is created before executing the
`dotnet dev-certs`.

### Checklist

- [x] I have added a Label to the pull-request
- [x] I have added tests, and done manual regression tests
- [x] I have updated the documentation, if necessary
  • Loading branch information
tjementum authored Dec 28, 2024
2 parents 2e13892 + 764e228 commit 80ad8b0
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions application/AppHost/SslCertificateManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,16 @@ private static void CreateNewSelfSignedDeveloperCertificate(string certificateLo

File.Delete(certificateLocation);
}
else
{
var certificateDirectory = Path.GetDirectoryName(certificateLocation)!;
if (!Directory.Exists(certificateDirectory))
{
Console.WriteLine($"Certificate directory {certificateDirectory} does not exist. Creating it.");

Directory.CreateDirectory(certificateDirectory);
}
}

Process.Start(new ProcessStartInfo
{
Expand Down

0 comments on commit 80ad8b0

Please sign in to comment.