如何创建 PFX 文件以在 Bit.IdentityServer 中使用?
How to create PFX file to use in Bit.IdentityServer?
我正在使用 Bit.IdentityService 来保护我的资源。为此,我需要一个 pfx 文件。
我可以把bit-foundation提供的sample project中的IdentityServerCertificate.pfx
文件复制到自己的项目中使用
但是,我不想使用该文件,而是想自己创建一个 pfx 文件,其密码不同于示例项目中使用的密码。
tools/approaches/solutions 可以创建 pfx 文件,与位框架兼容?
到目前为止,我已经完成了 this article 中的步骤,但它以错误告终,提示签名密钥的大小无效。通过兼容,我的意思是一种经过测试并且不会以此类错误结束的方法。
只需 运行 在 PowerShell 中使用您的 pfx 文件所需的密码和文件路径执行命令:
$cert = New-SelfSignedCertificate -CertStoreLocation Cert:\LocalMachine\My -Subject "IdentityServerCN" -Provider "Microsoft Strong Cryptographic Provider" -HashAlgorithm "SHA512" -NotAfter (Get-Date).AddYears(5)
Export-PfxCertificate -cert ('Cert:\LocalMachine\My\' + $cert.thumbprint) -FilePath PATH_TO_YOUR_IdentityServerCertificate.pfx -Password (ConvertTo-SecureString -String "YOUR_PASSWORD" -Force -AsPlainText)
然后在 environments.json 或 appsettings.json 文件中提供一个新密码。
我正在使用 Bit.IdentityService 来保护我的资源。为此,我需要一个 pfx 文件。
我可以把bit-foundation提供的sample project中的IdentityServerCertificate.pfx
文件复制到自己的项目中使用
但是,我不想使用该文件,而是想自己创建一个 pfx 文件,其密码不同于示例项目中使用的密码。
tools/approaches/solutions 可以创建 pfx 文件,与位框架兼容?
到目前为止,我已经完成了 this article 中的步骤,但它以错误告终,提示签名密钥的大小无效。通过兼容,我的意思是一种经过测试并且不会以此类错误结束的方法。
只需 运行 在 PowerShell 中使用您的 pfx 文件所需的密码和文件路径执行命令:
$cert = New-SelfSignedCertificate -CertStoreLocation Cert:\LocalMachine\My -Subject "IdentityServerCN" -Provider "Microsoft Strong Cryptographic Provider" -HashAlgorithm "SHA512" -NotAfter (Get-Date).AddYears(5)
Export-PfxCertificate -cert ('Cert:\LocalMachine\My\' + $cert.thumbprint) -FilePath PATH_TO_YOUR_IdentityServerCertificate.pfx -Password (ConvertTo-SecureString -String "YOUR_PASSWORD" -Force -AsPlainText)
然后在 environments.json 或 appsettings.json 文件中提供一个新密码。