16

The PowerShell command below creates a self-signed certificate with SHA1 as signature algorithm.

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

MyCertificate

Is there any value that I can pass to this command (for example: -KeyAlgorithm) to make the certificate generated using SHA256 as signature algorithm?

Believe2014
  • 3,894
  • 2
  • 26
  • 46

1 Answers1

27

KeyAlgorithm parameter defines the public key algorithm which is not related to signature algorithm (what you are trying to accomplish). Instead, you need to use -HashAlgorithm parameter and specify SHA256 as a parameter value:

New-SelfSignedCertificate -DnsName "MyCertificate", "www.contoso.com" `
    -CertStoreLocation "cert:\LocalMachine\My" `
    -Provider "Microsoft Strong Cryptographic Provider" `
    -HashAlgorithm "SHA256"
Crypt32
  • 12,850
  • 2
  • 41
  • 70