Dev Certs tool should handle "upgrading" certificates as necessary
See original GitHub issueIn .NET Core 3.0 we need to introduce an updated dev cert in order to handle changes in supported cipher suites in Windows (https://github.com/aspnet/AspNetCore/issues/8952). If the user already has the existing (pre-3.0) dev cert installed, they will get an error. In order to update, the user must run two commands:
dotnet dev-certs https --clean
dotnet dev-certs https --trust
These commands re-install the cert, ensuring it is the correct version.
I suggest we introduce a “versioning” element to the dev certificates and update the commands to make this experience cleaner for users.
- We augment the ASP.NET Core HTTPS Development Certificate extension to include an optional “version” value. I believe the extension can carry any raw data and that data is tagged with a size. It looks like we currently put the friendly name
ASP.NET Core HTTPS development certificatein as the content of this field. My suggestion would be to treat that as a “magic number” and allow additional fields to be specified immediately following it. So the logic would be as follows:- If the extension size equals the length of the ASCII friendly name, the version is presumed to be
0 - If the extension size is greater than the length of the ASCII friendly name, immediately following the final byte of the friendly name there must be a single byte indicating the version. This byte must be greater than or equal to
1 - Further data may be provided, as needed in the future. Where possible, tools that consume the certificate should ignore unnecessary additional fields
- As an alternative, if no tools are currently depending on the specific value of the extension, we could replace the extension content completely with our own format that includes a version and treat the ASCII
A(hex0x41) value as indicating version0(which by definition has no additional data). We would also have to prohibit the use of0x41to indicate a future version.
- If the extension size equals the length of the ASCII friendly name, the version is presumed to be
- The
dotnet dev-certs --checkaction will return a non-zero exit code and indicate an appropriate error message if a cert is present BUT the version of the installed cert pre-dates the version the tool provides. - The
dotnet dev-certsaction (no arguments), on detecting that a certificate already exists with an earlier version than the tool supports, will remove that certificate and install a new one with the appropriate version. - The
dotnet dev-certs --trustaction will similarly upgrade the cert and ensure the new cert is trusted.
Things to consider:
- An “upgrade” of the cert is “destructive”. A new certificate is generated. As long as nothing is pinning the thumbprint of this cert it should be OK. Since this is for development purposes, we shouldn’t be making guarantees that it will remain entirely unchanged anyway.
- Some platforms (i.e. Linux) don’t have a certificate store, so upgrades aren’t feasible here. We’ll just have to document this situation for those platforms since the user will have to manually manage the certificate anyway. Using the
--export-pathoption to export the certificate will export a new certificate that meets the new requirements anyway. - The version field in the certificate would, theoretically, allow Kestrel to detect an out-of-date certificate and either fail or produce a warning. That’s a topic for further discussion elsewhere though.
Issue Analytics
- State:
- Created 4 years ago
- Comments:15 (15 by maintainers)
Top Results From Across the Web
dotnet dev-certs command - .NET CLI
The dotnet dev-certs command manages a self-signed certificate to enable HTTPS use in local web app development. Its main functions are:
Read more >Configure localhost development dev certificate
After generating a new self-signed certificate you'll need to trust it in your OS's certificate store so it's recognized & treated as a...
Read more >How to force Visual Studio to re-create the SSL certificate ...
In powershell, re-run dotnet dev-certs https --trust to create and install a new one with the prompt to trust. It will work after...
Read more >Self-signed certificates or custom Certification Authorities
If you are using GitLab Runner Helm chart, you will need to configure certificates as described in Providing a custom certificate for accessing...
Read more >What is a certificate authority (CA)?
A certificate authority (CA) is a trusted entity that issues digital certificates to authenticate content sent from web servers. Learn about CAs here....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Acceptance will be handled by https://github.com/aspnet/AspNetCore/issues/10927
Filed https://github.com/aspnet/AspNetCore/issues/10927.