【问题标题】:How to create or generate JWKS key (use for encryption - enc) in identityserver4如何在 identityserver4 中创建或生成 JWKS 密钥(用于加密 - enc)
【发布时间】:2021-05-14 19:33:55
【问题描述】:

我想用 Identityserver4 为 jwks 端点实现 jwks 密钥,我已经检查了很多文章但没有人能解决我的要求 这是我的要求。

带有 3072 位密钥的 RSA 加密密钥

{
"kty": "RSA",
"use": "enc",
"kid": "enc-2021-01-15T12:09:06Z",
"e": "xxxxx",
"n": "xxxxx",
"alg": "RSA-OAEP-256"
}

【问题讨论】:

    标签: asp.net-core identityserver4 x509certificate public-key-encryption jwk


    【解决方案1】:

    我通常使用 OpenSSL 生成密钥,并使用下面的脚本生成私钥,然后将其与自签名证书一起放在 PKCS12 文件 (.pfx) 中。

    然后将 .pfx 文件导入 .NET 并使用 Identityserver AddSigningCredential 方法将其添加到 JWKS 端点。

    例如,此代码将证书加载到 .NET Core:

        private static SecurityKey LoadRsaKey()
        {
            var rsaCert = new X509Certificate2("rs256.pfx", "edument");
            SecurityKey rsaPrivateKey = new RsaSecurityKey(rsaCert.GetRSAPrivateKey());
            return rsaPrivateKey;
        }
    

    【讨论】:

    • 感谢分享,但还是没有解决我的问题
    • 具体是什么问题?生成密钥还是将其添加到 IdentityServer?
    猜你喜欢
    • 2021-05-12
    • 2014-08-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-03-15
    • 2018-02-10
    相关资源
    最近更新 更多