如何创建要在Bit.IdentityServer中使用的PFX文件



我正在使用Bit.IdentityService来保护我的资源。为此,我需要一个pfx文件。
我可以从 bit-foundation 提供的示例项目中复制IdentityServerCertificate.pfx文件并使用它。
但是,我想自己创建一个 pfx 文件,而不是使用示例项目中使用的密码。有哪些工具/方法/解决方案可以创建与位框架兼容的pfx文件?
到目前为止,我已经完成了本文中的步骤,但它以错误结束,告知签名密钥的大小无效。通过兼容,我的意思是一种经过测试并且不会以这种错误告终的方法。

只需在 PowerShell 中使用所需的密码和 pfx 文件路径运行以下命令:

$cert = New-SelfSignedCertificate -CertStoreLocation Cert:LocalMachineMy -Subject "IdentityServerCN" -Provider "Microsoft Strong Cryptographic Provider" -HashAlgorithm "SHA512" -NotAfter (Get-Date).AddYears(5)
Export-PfxCertificate -cert ('Cert:LocalMachineMy' + $cert.thumbprint) -FilePath PATH_TO_YOUR_IdentityServerCertificate.pfx -Password (ConvertTo-SecureString -String "YOUR_PASSWORD" -Force -AsPlainText)

然后在 environment.json 或 appsettings.json 文件中提供新密码。

最新更新