liveBook · Manning

Development certificate

As explained in .NET in Action, Second Edition

A development certificate is a locally trusted certificate used to support secure HTTPS connections during software development.

A development certificate makes it easier to test HTTPS endpoints locally. HTTPS protects requests and responses from being read or changed in transit. A publicly exposed service needs a certificate from a trusted authority; the development certificate addresses the different problem of local testing. section 3.1 section 9.3

Use the .NET CLI to manage trust on the machine running the service:

  • Run `dotnet dev-certs https --check` to check whether the development certificate is trusted. section 3.1
  • Run `dotnet dev-certs https --trust` to trust it on a development machine or CI/CD build agent. An IDE may already have set it up. section 3.1
Listing 3.2 Output from running the empty web service
> dotnet run
Building...
info: Microsoft.Hosting.Lifetime[14]
      Now listening on: https://localhost:7041       #1
info: Microsoft.Hosting.Lifetime[14]
      Now listening on: http://localhost:5292        #2
info: Microsoft.Hosting.Lifetime[0]
      Application started. Press Ctrl+C to shut down.

The service startup output shows separate HTTPS and HTTP localhost addresses. Use the HTTPS address when testing a secure endpoint. section 3.1

Certificate trust is distinct from redirecting traffic to HTTPS. In ASP.NET Core, `app.UseHttpsRedirection()` redirects an HTTP request to the HTTPS URL; a development certificate supports testing that HTTPS destination. section 3.1 section 9.3

How .NET in Action, Second Edition covers it

How deep it goes
Explains trust commands and their HTTPS role, but does not describe certificate internals.
Examples
Shows a local service listening on HTTPS and HTTP addresses alongside commands for checking and establishing certificate trust.
What it assumes
Assumes basic use of a .NET web-service project while spelling out the certificate trust commands.
What you can do after
Operate/configure it with `dotnet dev-certs https --check` and `dotnet dev-certs https --trust` for local or build-agent testing.
How it connects
Connects development certificates to HTTPS, ASP.NET Core services, and HTTP-to-HTTPS redirection.

Also explained in

Compare how 2 books explain development certificate →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of .NET in Action, Second Edition. The section links point to the parts of the book it draws on.