12

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?

Muhammad Rehan Saeed
  • 35,627
  • 39
  • 202
  • 311
  • 1
    For Azure pipelines you can use [secure files](https://learn.microsoft.com/en-us/azure/devops/pipelines/library/secure-files?view=azure-devops) – Pavel Anikhouski Jul 26 '19 at 14:13
  • How about using the approach mentioned in this? https://superuser.com/questions/191038/installing-deleting-root-certificate-without-certmgr-certutil-asking-the-end-u and https://stackoverflow.com/questions/4196997/certificate-install-security-warning-workaround – Tarun Lalwani Jul 28 '19 at 17:05

1 Answers1

9

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

d-cubed
  • 1,034
  • 5
  • 30
  • 58
cyptus
  • 3,346
  • 3
  • 31
  • 52