add or create 'Subject Alternative Name' field to self-signed certificate using makecert

wal picture wal · Jun 17, 2011 · Viewed 40.8k times · Source

How can I create a certificate using makecert with a 'Subject Alternative Name' field ?

enter image description here

You can add some fields eg, 'Enhanced Key Usage' with the -eku option and I've tried the -san option but makecert doesn't like it.

This is a self-signed certificate so any method that uses IIS to create something to send off to a CA won't be appropriate.

Answer

DanO picture DanO · Apr 28, 2017

An even easier way is to use the New-SelfSignedCertificate PowerShell commandlet, which includes a SAN by default. In a single command you can create the certificate and add it to the store.

New-SelfSignedCertificate -DnsName localhost -CertStoreLocation cert:\LocalMachine\My

Note that you need to run PowerShell as an administrator.