asp.net-core - IdentityServer4 中的签名凭证是什么?

标签 asp.net-core asp.net-identity identity identityserver4

我们正在使用我们的 .NET Core Web 应用程序实现 Identity Server 4。

我浏览了 Identity Server 文档。配置身份服务器(使用 DI)时,有一行:

.AddTemporarySigningCredential

我试图了解此签名凭据是什么,但无法弄清楚。因此,我不知道是否可以使用内置的临时工具,或者我是否应该提供不同的临时工具。

我的问题是,什么是签名证书,我应该如何使用它?

在身份服务器文档中,这是定义:

Adds a signing key service that provides the specified key material to the various token creation/validation services. You can pass in either an X509Certificate2, a SigningCredential or a reference to a certificate from the certificate store.



所以这似乎很重要:)

最佳答案

授权服务器将使用 key 对 token 进行签名。资源服务器应使用 key 验证 token 的完整性。它们一起形成一个(通常是非对称的,例如公钥/私钥) key (对)。默认情况下,IdentityServer 将通过 /.well-known/openid-configuration 发布用于验证 token 的公钥。端点。

对于开发场景,您通常希望跳过正确管理 key 等 secret 的大惊小怪(这对于在生产中正确执行非常重要!)。对于这些开发场景,您可以选择使用临时解决方案,例如 AddTemporarySigningCredential , 用于 .NET Core 1.x .

.NET Core 2.x 这将change你需要AddDeveloperSigningCredential()扩展方法。

这就回答了它是什么的问题。关于如何使用它:您只需根据您的 .NET Core 版本在 ConfigureServices(...) 中调用所需的方法。您的应用程序的 Startup 的方法类(class)。

除此之外,您不需要做任何特别的事情,当然要注意在生产中使用正确的 key 对。

另请参阅 Cryptography, Keys and HTTPS 上的文档和 the bit on Configuring Services for Keys .从后一个文档中,这是生产案例的相关替代方案:

  • AddSigningCredential

    Adds a signing key service that provides the specified key material to the various token creation/validation services. You can pass in either an X509Certificate2, a SigningCredential or a reference to a certificate from the certificate store.

关于asp.net-core - IdentityServer4 中的签名凭证是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46142991/

相关文章:

c# - 从 appSettings.json 获取值(value)?

asp.net-core - 带有 IIS 的 DotNetCore 2.2 应用程序无法工作 - HTTP 错误 500.0 - ANCM 进程内处理程序加载失败

asp.net - ASP.NET 5 类库(包)中的 .NET Platform 5.4 是什么?

c# - .NET Core 单元测试如何模拟 HttpContext RemoteIpAddress?

c# - Rolemanager 在 Identity 2.0 中始终为 null

c# - Controller 中的 ASP.NET Core MVC 子操作

c# - MVC 5 中具有 ASP.NET Identity 的 Autofac 不会验证 OWIN 管道中的安全标记

c# - ASP.net Identity 如何访问数据库,这是我应该使用的方式吗?

jQuery 编程风格?

identity - 结果身份改变