Question : How to Create self signed certificate using PowerShell?

Solution: A self-signed certificate is a certificate we sign with our own private key for testing purposes. Self signed certificate can be created with PowerShell using New-selfsignedcertificate. 

New-selfsignedcertificate -certstorelocation cert:\localmachine\my -dnsname iafs.itsamar.local

Self signed powershell

By default, a self-signed certificate is generated with the following settings:

  • Cryptographic algorithm: RSA
  • Key length: 2048 bit
  • Acceptable key usage: Client Authentication and Server Authentication;
  • Validity period: year.

To export the certificate as pfx file,

$certificate = New-SelfSignedCertificate -certstorelocation cert:\localmachine\my -dnsname iadf.https://amar365.com

$pwrd = ConvertTo-SecureString -String `P@ssw0rd123′ -Force -AsPlainText

$pathloc = ‘cert:\localMachine\my\’ + $certificate.thumbprint

Self signed certificate powershell

$certThumbprint = $certificate.Thumbprint

Thumbprint info can be stored as variable to use it later.

Also read : How to create self-signed certificate using IIS ?

By AMARNATH K

AM@RNATH is a Technology specialist primarily focus on Microsoft Technologies & Cloud Security. His certification includes M365 Certified: Enterprise Admin Expert. He loves to explore things from the latest technologies to cooking new recipes. Basically from Chennai, the southern part of India. Lucky son, friendly husband, and a proud father who loves to spend time with his family & friends while the laptop is not in his table.

Leave a Reply

Your email address will not be published.