Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to encrypt IdentityServer4 RSA certificates

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

How to carry out IdentityServer4 RSA certificate encryption, I believe that many inexperienced people do not know what to do. Therefore, this paper summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.

IdentityServer4 provides two certificate encryption configurations by default:

Services.AddIdentityServer () .AddDeveloperSigningCredential () .AddTemporarySigningCredential ()

These two certificate encryption methods are used temporarily. Each time the project is restarted, a new certificate will be generated again, which will lead to a problem. The access_token generated before restart will no longer be applicable after restart, because the corresponding encryption method has changed because the certificate has changed. Therefore, the following problem will occur:

Error message:

Www-Authenticate:Bearer error= "invalid_token", error_description= "The signature key was not found"

The solution is to always use a certificate. Let's configure it like this:

Services.AddIdentityServer () .AddDeveloperSigningCredential ()

You can check the AddDeveloperSigningCredential implementation source code and start the project. IdentityServer4 will generate a tempkey.rsa certificate file in the project directory:

{"KeyId": "4e1765de45ef639261115198826dfea7", "Parameters": {"D": "FnB7kIinBgoZDaRqIrRQHEF45FBF9amOrTn8oFdmsxPqJbh21bHeCw11AtCCC4p1mm750onDXeP+yoBHymr/wNn40VmGdhR4hnObHhhw5pyQKECIS41DFDatCZif9uhDgHsOvYHMRVNSapDFoDUvbTE6t7rv4prn2fDt5mzRD9AqdT2HyTcwa/H1haaZNwmy3UevYYy8ya4kKXvjRo6+O7BMBh+yBvHgezQ57Ye/NfZfDMITs4djbqELrYVXCTMltNsWWhQtS62cqvKboxoiXfSm67u/li5Fdusc5Z2zsyt5rE/V8h/ffBvS9N9v0VoDTdFqLYkuul0DvTZ/pqXtMQ==", "DP": "XQDf46csbwu/xX+jwo5VQQ8sKVlVBLuxSNTAbNS6O/aCg9eEjZ58EJ712JgqqORcDMg5JRejN3Zxxoij4roJogyvvw6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Tt3Yt

Code execution in AddDeveloperSigningCredential first determines whether the tempkey.rsa certificate file exists, if not, creates a new tempkey.rsa certificate file, and uses this certificate file if it does.

So, when we configure, pass a tempkey.rsa certificate file name, and it's fine:

Services.AddIdentityServer () .AddDeveloperSigningCredential ("tempkey.rsa")

Of course, you can also rename the tempkey.rsa certificate file.

After reading the above, have you mastered how to encrypt IdentityServer4 RSA certificates? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report