powershell script to create self signed certificate

powershell script to create self signed certificate

Problem -> Sometime while performing any application test or configuring test environment it is difficult to buy certificate so better option is to use self sigh certificate.

There are multiple ways to generate self sign certificate, Prior to PowerShell 4.0, you needed to download MakeCert.exe or another utility to create self signed certificates. Obtaining MakeCert involved jumping through a number of hoops, but now microsoft included command in powershell 4.0 which have direct command to get self sign certificate.

 

Solution 1 ->

The commands you need are New-SelfSignedCertificate. The way you use them is as follows.

First – you need the FQDN that you want to use for the certificate. For example-  app.vedtechno.com . You then use below command and you will get self sign cert in “localmachinemy” store…

ex-

New-SelfSignedCertificate -certstorelocation cert:localmachinemy -dnsname  app.vedtechno.com

 

Solution 2 -> if you dont have ps 4.0 and New-SelfSignedCertificate command then you can still use self sign certificate generator  NewSelfsignedCertificateEx on –https://gallery.technet.microsoft.com/scriptcenter/Self-signed-certificate-5920a7c6

Ex –

New-SelfsignedCertificateEx -Subject "CN=Test Code Signing" -EKU "Code Signing" -KeySpec "Signature" ` 
-KeyUsage "DigitalSignature" -FriendlyName "Test code signing" -NotAfter $([datetime]::now.AddYears(5))
(Visited 1,288 times, 1 visits today)
One Comment

Add a Comment

Facebook