Create a self-signed certificate with New-SelfSignedCertificate

Windows' built-in certificate authority in one cmdlet — issue test TLS certificates into the machine store for local HTTPS and IIS bindings.

WindowscertificatessecuritypowershellMedium risk
Run `New-SelfSignedCertificate -DnsName dev.local -CertStoreLocation Cert:\LocalMachine\My` as administrator to issue a certificate for that name.

01Command

Command
$ New-SelfSignedCertificate -DnsName dev.local -CertStoreLocation Cert:\LocalMachine\My

02What it does

This cmdlet creates a real X.509 certificate with the SAN you specify and drops it straight into the chosen store — no openssl config files needed. The default produces a certificate with modern key usage; add `-NotAfter (Get-Date).AddYears(2)` to control lifetime and `-FriendlyName` to find it later. Browsers will still warn until you copy the certificate into Trusted Root (Cert:\LocalMachine\Root) or bind it in IIS/Kestrel with its thumbprint.

03Risk

RiskMedium risk
RequirementsMust run in an elevated PowerShell. Trust it by copying the cert to Cert:\LocalMachine\Root.
!Warning: Self-signed certificates must never be trusted for public traffic; adding them to the Root store trusts everything signed by that key on this machine.

04Undo

Undo
$ Remove-Item Cert:\LocalMachine\My\<thumbprint>

05Sources

  • New-SelfSignedCertificate | Microsoft Learn
    Microsoft · vendor-doc · 2026-09-17
    Evidence: Microsoft documents New-SelfSignedCertificate parameters -DnsName and -CertStoreLocation and notes it creates a self-signed test certificate.

Last verified: 2026-09-17 · Category: Security & Privacy

06Related solutions