How to create a self-signed public certificate - Powershell

In this post, I describe how to create a self-signed public certificate using Powershell.

Screenshot of a certificate in the certificates MMC

Resolution

To create a self-signed public certificate in the current user's certificate store, in a PowerShell prompt, enter the following (changing the certificate name as required):

$certname = "SelfSignedCertificate"

$cert = New-SelfSignedCertificate -Subject "CN=$certname" -CertStoreLocation "Cert:\CurrentUser\My" -KeyExportPolicy Exportable -KeySpec Signature -KeyLength 2048 -KeyAlgorithm RSA -HashAlgorithm SHA256

Screenshot of PowerShell running the New-SelfSignedCertificate cmdlet

The certificate should now be visible in the Certificates MMC.


Export

To export the self-signed public certificate in .cer format using the $cert variable from the previous command, enter the following (changing the file path as required):

Export-Certificate -Cert $cert -FilePath "C:\Users\sysadmin\Desktop\$certname.cer"

Screenshot of PowerShell running the Export-Certificate cmdlet

This post was based on information from this Microsoft page:

- Create a self-signed public certificate to authenticate your application


Related Posts

- Mismatched Address certificate error - HTTPS localhost IIS

- The hostname in the website’s security certificate differs from the website you are trying to visit.

Comments

Popular posts from this blog

LG TV This app will now restart to free up more memory

LG TV Clear All Browsing History Data

LG TV turn off Quick Start in settings