✅ Step-by-Step: Create & Install Self-Signed Certificate in PowerShell
✅ Step-by-Step: Create & Install Self-Signed Certificate in PowerShell
π¦ Step 1: Open PowerShell as Administrator
1. Click Start
2. Search PowerShell
3. Right-click → Run as Administrator
π¦ Step 2: Create a Self-Signed Certificate
Use this command:
New-SelfSignedCertificate -DnsName "test.local" -CertStoreLocation "Cert:\LocalMachine\My"
π What this does:
Generates a certificate for domain test.local
Saves it under Local Machine → Personal → Certificates
π¦ Step 3: Export Certificate With Private Key (Optional)
If you want a .pfx (for IIS / apps), run:
3.1 Set a password
$mypwd = ConvertTo-SecureString -String "P@ssw0rd123" -Force -AsPlainText
3.2 Export to PFX
Export-PfxCertificate -Cert "Cert:\LocalMachine\My\<Thumbprint>" `
-FilePath "C:\certs\mycert.pfx" -Password $mypwd
π Replace <Thumbprint> with your certificate’s real thumbprint:
Get-ChildItem Cert:\LocalMachine\My
π¦ Step 4: Export .CER (For Trusted Root Installation)
Export-Certificate -Cert "Cert:\LocalMachine\My\<Thumbprint>" `
-FilePath "C:\certs\mycert.cer"
π¦ Step 5: Install Certificate to Trusted Root (Fix Browser Errors)
Method 1: PowerShell (Automatic)
Import-Certificate -FilePath "C:\certs\mycert.cer" -CertStoreLocation "Cert:\LocalMachine\Root"
Method 2: Manual
1. Press Win + R → type certmgr.msc
2. Go to:
Trusted Root Certification Authorities → Certificates
3. Right-click → All Tasks → Import
4. Select your .cer file → Finish
π¦ Step 6: Verify Installation
Run:
Get-ChildItem Cert:\LocalMachine\Root | Where-Object {$_.Subject -like "*test.local*"}
If it shows up → certificate installed successfully ✔️
π― OPTIONAL: Create SSL Certificate for IIS
New-SelfSignedCertificate -DnsName "myapp.local" -CertStoreLocation Cert:\LocalMachine\My -FriendlyName "MyApp SSL"
Bind in IIS:
1. Open IIS Manager
2. Site → Bindings
3. Add https
4. Select your certificate
π Done!
If you want, I can also provide: ✅ Script to automate entire process
✅ Wildcard cert creation (*.domain.local)
✅ Adding certificate to IIS automatically
Would you like the full automation PowerShell script?
Comments
Post a Comment