.netcertificateazure-pipelinesdotnet-clidotnet-dev-certs

How to Install dotnet dev-certs certificate on a CI Server


I would like to run my API using dotnet run, so I can run some tests against it. However, on Azure Pipelines and AppVeyor, they don't have a developer certificate installed and I get an error when I try to start my API. Installing a developer certificate involes running:

dotnet dev-certs https --trust

However, this shows a dialogue which the user has to click and this fails the build. How can I install the developer certificate on a CI server?


Solution

  • You can either use your own certificate (aspnet core listenOptions.UseHttps(new X509Certificate2(...));) in your app or export the dotnet dev certificate with:

    dotnet dev-certs https --export-path <path> [--password <pass>]
    

    This generates the certificate that you need. You can trust this certificate manually with powershell as explained here:

    https://stackoverflow.com/a/49444664/1216595 or https://stackoverflow.com/a/21001534/1216595