How to Install dotnet dev-certs certificate on a CI Server
See original GitHub issueDescribe the bug
I would like to run my API using dotnet run
, so I can run some tests against it on my CI server. 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?
My scenario is that I want to run functional tests against my dotnet new
project templates by actually running them. Here is an example of my unit test:
public async Task Run_HealthCheckFalse_Successful()
{
using (var tempDirectory = TemplateAssert.GetTempDirectory())
{
var project = await tempDirectory.DotnetNew(
"api",
"HealthCheckFalse",
new Dictionary<string, string>() { { "health-check", "false" } });
await project.DotnetRestore();
await project.DotnetBuild();
await project.DotnetRun(
@"Source\HealthCheckFalse",
async httpClient =>
{
var statusResponse = await httpClient.GetAsync("status");
Assert.Equal(HttpStatusCode.NotFound, statusResponse.StatusCode);
});
}
}
Expected behavior
I should be able to install the dev certificate without UI. I expected the --quiet
flag to do this but that was not the case.
Screenshots
This is the dialog that appears on Windows:
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (6 by maintainers)
Useful info here:
https://stackoverflow.com/questions/57221762/how-to-install-dotnet-dev-certs-certificate-on-a-ci-server/57274470
Local Machine would, I believe, prompt a dialog too. As I said earlier we wouldn’t ever provide a non-prompting version
And yes, you can export the certificate from a dev machine and install it into the stores on the CI machine, then also trust it and away you go. Or just run the dev-certs command on the CI machine itself interactively and confirm the trust dialog