How to quickly create a dummy / self-signed certificate for sandbox testing

This is quick, simple recipe on how to creat a self-signed .pfx certificate for your sandbox in 1 minute using powershell.

Step 1 - Create a new a self-signed certificate

The New-SelfSignedCertificate cmdlet enables you to create a self-signed certificate.

$cert = New-SelfSignedCertificate -DnsName www.domainname.co.za `
-Type CodeSigning -CertStoreLocation Cert:\CurrentUser\My

Step 2 - Verify that the certificate has been generated

Get-ChildItem -Path Cert:\CurrentUser\My | ? Subject -EQ “CN=www.domainname.co.za”

Step 3 - Export the certificate

Export the certificate using the Export-PfxCertificate cmdlet into a local directory of your choosing. Save the password in safe place.

$CertPassword = ConvertTo-SecureString -String “P@ssw0rd111” -Force –AsPlainText
Export-PfxCertificate -Cert “cert:\CurrentUser\My\$($cert.Thumbprint)” `
-FilePath “c:\allensselfsignedcert\AllensCertificate.pfx” -Password $CertPassword

3 comments

Leave a comment

Your email address will not be published. Required fields are marked *