Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using an Identity Server signing certificate in Azure

In the IdentityServer sample code (startup.cs), we can see how to use a certificate:

var certFile = env.ApplicationBasePath + "\\idsrv3test.pfx";

var signingCertificate = new X509Certificate2(certFile, "idsrv3test");

How do I do this in a production environment, if I am deploying my STS to Azure as a Web App Service?

For security, I know I cannot add the pfx file to the solution.

like image 201
Karl Gjertsen Avatar asked Jan 03 '17 13:01

Karl Gjertsen


1 Answers

Upload certificate to the portal:

https://docs.microsoft.com/en-us/azure/app-service-web/web-sites-configure-ssl-certificate#step-2-upload-and-bind-the-custom-ssl-certificate

Now you can get certificate by:

        var certStore = new X509Store(StoreName.My, StoreLocation.CurrentUser);
        certStore.Open(OpenFlags.ReadOnly);

        var certCollection = certStore.Certificates.Find(
            X509FindType.FindByThumbprint, certificateThumbprint, false);
        var signingCertificate = certCollection[0];

        certStore.Close();
like image 135
Alexander S. Avatar answered Sep 28 '22 00:09

Alexander S.



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!