Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
336 views
in Technique[技术] by (71.8m points)

c# - Accessing certificate in Azure KeyVault from ASP.NET Core app

I have created a Blazor WebAssembly app with a server backend using Identity Server out-of-box (from the template).

I want to publish it to Azure but I don't get it working with loading the certificate from Azure KeyVault.

I have used the wizards in Visual Studio to generate the boilerplate code. Everything has been configured too.

And I read this guide too: https://docs.microsoft.com/en-us/aspnet/core/blazor/security/webassembly/hosted-with-identity-server?view=aspnetcore-5.0&tabs=visual-studio#host-in-azure-app-service-with-a-custom-domain

And I have created a certificate in the Key Vault named IdentityServerSigning with CN=IdentityServerSigning.

When I then run the app I get 500.30.

Opening the Web-based Console from the Portal, I launch the app and get that it could not find a valid certificate 'CN=IdentityServerSigning' on the 'CurrentUser/My'.

What am I missing?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I guess you may forget to add application setting on portal, if your code has no problem.

We need to give Azure App Service permission to use the newly uploaded certificate. For that:

  1. Go to Configuration in the menu of your Azure App Service
  2. Click on New application setting
  3. In Name, put: WEBSITE_LOAD_CERTIFICATES
  4. In Value, put the Thumbprint that you copied from the previous section.
  5. Click Ok, and don’t forget to click Save

If it doesn't work, pls read below blogs, you will find out the issues.

Suggestion

You can refer to this blogs to check the steps, I believe it will useful to you.

Blazor: Using a Self-Signed Certificate for IdentityServer4 in Azure App Service


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...