Dot-Net

SHA256 的密鑰算法

  • April 20, 2016

下面的PowerShell 命令創建一個使用 SHA1 作為簽名算法的自簽名證書。

New-SelfSignedCertificate -DnsName "MyCertificate", "www.contoso.com" -CertStoreLocation "cert:\LocalMachine\My" -Provider "Microsoft Strong Cryptographic Provider"

我的證書

是否有任何值可以傳遞給此命令(例如-KeyAlgorithm:)以使用 SHA256 作為簽名算法生成證書?

KeyAlgorithm參數定義與簽名算法無關的公鑰算法(您要完成的工作)。相反,您需要使用-HashAlgorithm參數並指定SHA256為參數值:

New-SelfSignedCertificate -DnsName "MyCertificate", "www.contoso.com" `
   -CertStoreLocation "cert:\LocalMachine\My" `
   -Provider "Microsoft Strong Cryptographic Provider" `
   -HashAlgorithm "SHA256"

引用自:https://stackoverflow.com/questions/36733439