Skip to content

Allow passing base64 pfx content as HTTPS certificate #52062

Open
@Gerhut

Description

@Gerhut

Is there an existing issue for this?

  • I have searched the existing issues

Is your feature request related to a problem? Please describe the problem.

I am trying to apply the HTTPS certificate stored in Azure KeyVault with Krestel server using KeyVault Configuration Provider. By KeyVault Configuration Provider, certificates could be retrieved as secrets in base64-pfx format, while Krestel configuration does not support passing the base64 pfx content directly. Now I have to do either:

Suppose I store the certificate in Azure KeyVault with name Krestel--Certificates--Default--Content

// Program.cs

File.WriteAllBytes("https.pfx", Convert.FromBase64String(builder.Configuration["Krestel:Certiticates:Default:Content"]));
{
  "//": "appsettings.json",
  "Krestel": {
    "Certificates": {
      "Default": {
        "Path": "https.pfx"
      }
    }
  }
}

or

// Program.cs

builder.Services.Configure<KestrelServerOptions>(options =>
{
    options.ConfigureHttpsDefaults(httpsOptions =>
    {
        httpsOptions.ServerCertificate = new(Convert.FromBase64String(builder.Configuration["Krestel:Certificates:Default:Content"]));
    });
});

Describe the solution you'd like

It will be great if we can directly support the key like Krestel:Certificates:Default:Content with base64 encoded pfx format. This will make we migrate from http to https with certs in Azure KeyVault more smoothly - no need to change the code and recompile or write some preprocesses to download the cert to local, just add some fields to configuration and all set.

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-networkingIncludes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractionsfeature-kestrel

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions