Skip to content

Vaultsharp & Pki : how to generate certificat on-the-fly for Kestrel #233

Closed Answered by theazyfa
theazyfa asked this question in Q&A
Discussion options

You must be logged in to vote

Hi,
i find it.
If someone want to do it (c# 6.0 / Kestrel /SSL on-the-fly)
/!\ Warning : it's a poc, not a clean code ;)

Vault part

https://learn.hashicorp.com/tutorials/vault/pki-engine

.Net part

Somewhere in your starter files , you give SSL Certificat to kestrel :

...
webBuilder
    .UseConfiguration(Program.Configuration)
    .UseStartup<Startup>()
    .UseKestrel(options =>
    {
        options.Listen(IPAddress.Loopback, 44327, listenOptions =>
        {
            var serverCertificate = LoadCertificate();
            listenOptions.UseHttps(serverCertificate);
        });
    })
...

and the method call to generate the certificat.

        private static X509Certificate2 LoadCertif…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by theazyfa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant