How to create a self-signed public certificate - Powershell
In this post, I describe how to create a self-signed public certificate using Powershell.
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
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"
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
Post a Comment