Skip to content

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

@RehanSaeed

Description

@RehanSaeed

Describe 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:

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-commandlinetoolsIncludes: Command line tools, dotnet-dev-certs, dotnet-user-jwts, and OpenAPI

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions