SHA256的KeyAlgorithm

Bel*_*014 12 .net powershell msdn x509certificate2

下面的PowerShell命令创建一个自签名证书,其中SHA1作为签名算法.

New-SelfSignedCertificate -DnsName "MyCertificate", "www.contoso.com" -CertStoreLocation "cert:\LocalMachine\My" -Provider "Microsoft Strong Cryptographic Provider"
Run Code Online (Sandbox Code Playgroud)

MyCertificate

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

Cry*_*t32 19

KeyAlgorithm参数定义了与签名算法无关的公钥算法(您要完成的任务).相反,您需要使用-HashAlgorithm参数并指定SHA256为参数值:

New-SelfSignedCertificate -DnsName "MyCertificate", "www.contoso.com" `
    -CertStoreLocation "cert:\LocalMachine\My" `
    -Provider "Microsoft Strong Cryptographic Provider" `
    -HashAlgorithm "SHA256"
Run Code Online (Sandbox Code Playgroud)