Skip to content

Instantly share code, notes, and snippets.

@tcartwright
Created August 25, 2025 16:05
Show Gist options
  • Save tcartwright/5f529150e5fd686d80f442dae141f0c5 to your computer and use it in GitHub Desktop.
Save tcartwright/5f529150e5fd686d80f442dae141f0c5 to your computer and use it in GitHub Desktop.
POWERSHELL: Generate a cert
# IMPORTANT: !!Generated certs should NOT be used in production!!
$cert = New-SelfSignedCertificate `
-Subject "CN=sso.servername.it" `
-KeyAlgorithm RSA `
-KeyLength 2048 `
-CertStoreLocation "Cert:\CurrentUser\My" `
-NotAfter (Get-Date).AddYears(5) `
-KeyExportPolicy Exportable `
-Type Custom `
-TextExtension @("2.5.29.37={text}1.3.6.1.5.5.7.3.3") # Code signing usage
$pwd = ConvertTo-SecureString -String "yourStrongPassword" -Force -AsPlainText
Export-PfxCertificate `
-Cert "Cert:\CurrentUser\My\$($cert.Thumbprint)" `
-FilePath "C:\sso.pfx" `
-Password $pwd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment