Skip to content

makecert and creating ssl or signing certificates

June 1, 2015

I’ve been asked to post my makecert scripts for creating self-signed certificates (one for SSL and the other for signing). I use both of these scripts as .bat files. These scripts accept one parameter — the CN (common name) you want the certificate to match. For the SSL cert this must match the host name. For signing it’s just a unique name. Both of these need to be run from an administrative command prompt because the scripts install the certificate into the local machine’s personal certificate store. If you need the public key portion (.cer) then you’d have to open mmc and export it. Also, notice the expiration in the scripts — this is something you might want to change based upon your situation.

The first script is for creating SSL certificates. This is good for setting up SSL on your local IIS for a new web site (you’d need to ensure the host is indicated and SNI is configured). Although the SSL certificate won’t be trusted until you configure the cert as trusted on the client machine. Here are the .bat file contents:

makecert -r -pe -n "CN=%1" -b 01/01/2015 -e 01/01/2020 -eku 1.3.6.1.5.5.7.3.1 -sky exchange -a sha256 -len 2048 -ss my -sr localMachine

The second script is for creating signing certificates (for things like token signing within a token service such as IdentityServer). Here are the .bat file contents:

makecert -r -pe -n "CN=%1" -b 01/01/2015 -e 01/01/2020 -eku 1.3.6.1.5.5.7.3.3 -sky signature -a sha256 -len 2048 -ss my -sr LocalMachine

HTH

 

5 Comments leave one →
  1. June 2, 2015 11:21 pm

    HI Brock

    This link might be interesting as well, shows how to make a cert using makecert or openssl and setup your windows system.

    https://damienbod.wordpress.com/2014/04/16/iis-https-configuration-for-team-development/

    greetings Damien

  2. June 20, 2016 3:54 pm

    Any guides you might be aware of that show how to install on IIS 8?

    • June 24, 2016 2:10 pm

      no sorry — i’d check/ask microsoft for into on this.

    • September 3, 2016 3:36 am

      I compiled letsencrypt-win-simple, and then ran it on my server and it installed automatically a valid IIS 8.5 X509 cert and updated IIS to use it. A full video demo is on this page.
      —https://github.com/Lone-Coder/letsencrypt-win-simple/wiki/How-to-Compile-From-Source-Code
      Seems only to work with, I have to figure out how to use it with my NON-MS NON-Web based email server.

      The github link is here:
      —https://github.com/Lone-Coder/letsencrypt-win-simple

      And a video explaining how/why you are getting free X509 certs that can auto renew is here:
      —https://www.youtube.com/watch?v=OE5UhQGg_Fo

      However, I still don’t know much about certs, and am trying to get (automate) a cert with openssl for IdenityServer3, hopefully by tonight.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: