SHA256 的密钥算法

KeyAlgorithm for SHA256

下面的 PowerShell command 创建一个使用 SHA1 作为签名算法的自签名证书。

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

是否有任何值可以传递给此命令(例如:-KeyAlgorithm)以生成使用 SHA256 作为签名算法的证书?

KeyAlgorithm 参数定义了 public 密钥算法,它与签名算法(您要完成的)无关。相反,您需要使用 -HashAlgorithm 参数并将 SHA256 指定为参数值:

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