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
706 views
in Technique[技术] by (71.8m points)

asp.net core - Azure web app "Couldn't find a valid certificate"

So I created an ASP.NET Core website with IdentityServer authentication and published it to my Azure Web App but it complains about the certificate. I'm just using the default basic 1 tier web app with no custom domain. The web app is signed by a certificate out of the box so can't I just use that somehow?

Do I really need to buy a custom domain and my own certificate for this to work? I would prefer if I can just keep using the web app without a custom domain.

In the diagnostics dump I can see the error

   Couldn't find a valid certificate with subject 'CN=MyApplication' on the 'CurrentUserMy'
   at Microsoft.AspNetCore.ApiAuthorization.IdentityServer.SigningKeysLoader.LoadFromStoreCert(String subject, String storeName, StoreLocation storeLocation, DateTimeOffset currentTime)
   at Microsoft.AspNetCore.ApiAuthorization.IdentityServer.ConfigureSigningCredentials.LoadKey()
   at Microsoft.AspNetCore.ApiAuthorization.IdentityServer.ConfigureSigningCredentials.Configure(ApiAuthorizationOptions options)

Startup.cs

        var identityserver = services.AddIdentityServer();
        identityserver.AddApiAuthorization<ApplicationUser, AutheticationDbContext>();
        identityserver.AddSigningCredentials();

        services.AddAuthentication()
            .AddIdentityServerJwt();

appSettings.json

  "IdentityServer": {
    "Clients": {
      "MyWebProjectName.Client": {
        "Profile": "IdentityServerSPA"
      }
    },
    "Key": {
      "Type": "Store",
      "StoreName": "My",
      "StoreLocation": "CurrentUser",
      "Name": "CN=MyApplication"
    }
  }
question from:https://stackoverflow.com/questions/65937953/azure-web-app-couldnt-find-a-valid-certificate

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

1 Answer

0 votes
by (71.8m points)

When you deploy your webapp, you will get a url like: https://appname.azurewebsites.net.

Do I really need to buy a custom domain and my own certificate for this to work?

Then you can use powershell to generate self signed certificate. So you don't need to create a new domain or buy certificate.

After deployed app, you also need to upload your self signed certificate on portal, like Syarif Mathis's answer on below post.

How to configure key settings for IdentityServer in appsettings.json for aspnet core app running on IIS


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

2.1m questions

2.1m answers

60 comments

57.0k users

...