How to configure a Self-Signed Server Certificate for your local development environment

A lot of the times when I am working on a clients site locally I find myself in need of a Server Certificate for my local development site. 

Since all the clients other environments (QA, Stage, Production etc) is running HTTPS in makes no sense to run my local site over HTTP. Also a lot of clients use Identity Providers that requires me to communicate over HTTPS to be able to authenticate so not having a certificate is not an option.

In this blogpost I thought I would share a little exercise where we first setup a static site in IIS without a certificate and then later add a self signed certificate an attach to that same site. Enjoy!


Create a static site in IIS

  1. Create a static site using an index.html file in a local folder.


  2. Open IIS Manager (if you don’t have IIS Manager you need to enable this feature in Windows Features.)



  3. Create a site by right-click Sites and add these configurations:
  4. Open C:\Windows\System32\drivers\etc\hosts file and add this line at the very bottom:
    127.0.0.1                                    mysite.local

  5. Done! Now you can open your browser and navigate to http://mysite.local to see your site!

Adding a self-signed certificate

  1. Now go to IIS Manager > IIS > Server Certificates:
  2. In the Actions sidebar click ”Create Self-Signed Certificate” and assign a friendly (any) name to your certificate:
  3. Next you go back to Sites and right-click mysite.local and select Edit Bindings and then click Add. Make sure you select Type=https and select your newly create certificate.
  4. Done! Now you can open your browser again but this time navigate to https://mysite.local
    (Be aware that the first time you request this page you will get a warning saying this connection is not secure, just approve it and you should then arrive at the site).

Be aware that your browser will still say that this site is not using a valid certificate, which is true. We aren’t using a trusted certificate, we are using our own ”fake” certificate. However this can just be ignored when you are developing locally and communication between for example an Identity Provider that requires HTTPS will work just fine.

Hope this may help someone.

Cheers friends! ❤️