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
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: 1 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
$certThumbprint = $certificate.Thumbprint
Thumbprint info can be stored as variable to use it later.
Also read : How to create self-signed certificate using IIS ?