Skip to content

Instantly share code, notes, and snippets.

@magohl
Last active October 11, 2022 14:42
Show Gist options
  • Save magohl/98dab37dfca8059517bfd675eb735660 to your computer and use it in GitHub Desktop.
Save magohl/98dab37dfca8059517bfd675eb735660 to your computer and use it in GitHub Desktop.
powershell - generate certificate
// example using an ip as SAN subject alternate name
New-SelfSignedCertificate -NotBefore (Get-Date) -NotAfter (Get-Date).AddYears(1) -Subject "idp" -KeyAlgorithm "RSA" -KeyLength 2048 -HashAlgorithm "SHA256" -CertStoreLocation "Cert:\CurrentUser\My" -KeyUsage KeyEncipherment -FriendlyName "192.168.43.1 development certificate v2" -TextExtension @("2.5.29.19={critical}{text}","2.5.29.37={critical}{text}1.3.6.1.5.5.7.3.1","2.5.29.17={critical}{text}DNS=192.168.43.1&IPAddress=192.168.43.1")
// Client authentication only. 10years
New-SelfSignedCertificate -Type Custom -Subject "CN=kramerica-xyz-dev-spn,O=Kramerica SelfSigned DEV" -KeyUsage DigitalSignature -KeyLength 4096 -KeyAlgorithm RSA -HashAlgorithm "SHA512" -TextExtension @("2.5.29.37={text}1.3.6.1.5.5.7.3.2") -NotAfter (Get-Date).AddYears(10) -CertStoreLocation "Cert:\LocalMachine\My"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment