SSL on LocalHost with MAMP Pro for Windows
This tutorial will demonstrate how to get SSL certs working easily when using a Windows computer and Mamp Pro for Windows.
Almost all developers work on their sites locally. How you get a local host setup varies from developer to developer. Some use Docker or Valet but a very popular localhosting set up is MAMP Pro which is available for both Mac and Windows. As a windows user I've been using MAMP Pro since the windows version was released.
The one area that I was unable to resovle was getting SSL to work with my local domains. The self signed certificates never seemed to work correctly.
Today on twitter I saw a link to mkcert and it appears to be super easy to use and works with Windows, Mac, and Linux so I gave it a shot. 10 minutes later I had 2 of my sites working with SSL. Here's how.
Local version of this site using https
How To Install
- For windows users go to the pre-built binaries and download the one ending in .exe - save this to a folder on your hard drive where you'd like all your certificates to end up. For me I saved it in
D:\certs
- Open up your terminal and navigate to the folder above and then run this command:
mkcert-v1.3.0-windows-amd64.exe -install
This command only needs to be run the first time. - Next you'll create your first certificate
mkcert-v1.3.0-windows-amd64.exe domain.test
this will create two filesdomain.test.pem
anddomain.test-key.pem
. Mamp pro cannot work with these so you need to convert them.
At this point you may need to install openssl if you haven't already.
- Convert the first file to a .cert with this command:
openssl x509 -outform der -in domain.test.pem -out domain.test.cert
- and then convert the key file with this command:
openssl pkey -in domain.test-key.pem -out domain.test.key
- The final step is to open up your Mamp control panel navigate to your domain and go to the SSL tab and enable it and then link to the .cert and .key files you've created.
Restart Mamp and you now have https working locally.