How to Create Self-Signed Certificates ​Using PowerShell​! Within 2 Minutes!

Опубликовано: 28 Август 2024
на канале: The Journey of DevOps
596
20

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"


Смотрите видео How to Create Self-Signed Certificates ​Using PowerShell​! Within 2 Minutes! онлайн, длительностью часов минут секунд в хорошем качестве, которое загружено на канал The Journey of DevOps 28 Август 2024. Делитесь ссылкой на видео в социальных сетях, чтобы ваши подписчики и друзья так же посмотрели это видео. Данный видеоклип посмотрели 596 раз и оно понравилось 20 посетителям.