Step-by-step PowerShell commands with explanations.
Generate the Certificate –
$cert = New-SelfSignedCertificate -DnsName "test.com" -CertStoreLocation "cert:\LocalMachine\My"
$cert – Variable to store the value
New-SelfSignedCertificate – PowerShell command
-DnsName – Certificate Name
CertStoreLocation - certificate store (This cannot be file path)
Export the Certificate –
Export-PfxCertificate -Cert $cert -FilePath "D:\test\certificate.pfx" -Password (ConvertTo-SecureString -String "password" -Force -AsPlainText)
Export-PfxCertificate - PowerShell command
-Cert – Certificate Location
-FilePath – where you want to export the certificate
-Password – Password for .pfx file
Export the Private Key–
openssl pkcs12 -in "D:\test\certificate.pfx" -nocerts -out "D:\test\privateKey.pem" -nodes -passin pass:password
-in - Specifies the input .pfx file.
-nocerts - Tells OpenSSL to only extract the private key, without the certificate.
-out - Specifies the output file for the private key.
-nodes - Ensures that the private key is not encrypted.
-passin – Provide the export password.
Export the Certificate –
openssl pkcs12 -in "D:\test\certificate.pfx" -clcerts -nokeys -out "D:\test\certificate.pem"-passin pass:password
-in - Specifies the input .pfx file.
clcerts option tells OpenSSL to only output the client certificate.
-nokeys - Tells OpenSSL to only extract the certificate, without the private key.
-out - Specifies the output file for the PEM file.
-passin – Provide the export password.
Convert PEM to CRT Format–
openssl x509 -outform der -in "D:\test\certificate.pem" -out "D:\test\certificate.crt"
Watch video How to Create Self-Signed Certificates Using PowerShell! Within 2 Minutes! online, duration hours minute second in high quality that is uploaded to the channel The Journey of DevOps 28 August 2024. Share the link to the video on social media so that your subscribers and friends will also watch this video. This video clip has been viewed 596 times and liked it 20 visitors.