AddSigningCredential for IdentityServer4

后端 未结 3 1406
不思量自难忘°
不思量自难忘° 2021-02-05 10:05

We are using IdentityServer4 with .NET Core Web Application(\"http://docs.identityserver.io/en/release/quickstarts/0_overview.html\"). We have replaced AddDeveloperSigning

3条回答
  •  有刺的猬
    2021-02-05 10:33

    Here is a simple way of using the X509 self-signed certificate.

    One way to use a self-signed certificate to use for token signing with IdentityServer4 is to store the certificate with the application under the 'wwwroot' folder.

    public void ConfigureServices(IServiceCollection services)
    {
            .....other code .....
    
            var fileName = Path.Combine(env.WebRootPath, "YOUR_FileName" );            
    
            if (!File.Exists(fileName))
            {
                throw new FileNotFoundException("Signing Certificate is missing!");
            }
    
            var cert = new X509Certificate2(fileName, "Your_PassPhrase" );
    
            services.AddIdentityServer().AddSigningCredential(cert)
    
            ...other code.....
    }
    

提交回复
热议问题