Enable SSL for Localhost using MAMP
A SSL or Socket Secure Layer helps you to make your website secure. SSL can encrypt data transactions between the server and the browser. Hence, it is vital to check websites in a SSL environment in the very early steps of the site’s development.
Enable the SSL
Launch the MAMP firstly. Then create a Virtual Host with a custom domain. This custom domain can be set up in extensions like .dev or .local. As an example, we have created www.hongkiat.dev which is used to host www.hongkiat.com.
Each virtual host created in MAMP will have the individual option on which you are able to do some configurations.
In order to enable SSL for the virtual host, go to the SSL tab and tick the SSL option. Thereafter, locate the SSL certificate files. If you found one, assign it. If not, click the ‘Create Self-Signed Certificate’ button. This allows MAMO to create the certificates for you.
In the creation process, you will be asked information like Country Code, State, etc. by the MAMP.
Save the file in proper folder. SSL is now set.
Make Chrome Trust Your Website
Once you have set the SSL, you should be able to view your website through the https protocol. However, you see an error message. This is because the SSL certificate is not recognized by the browsers. In our case, the browser is Google Chrome. For websites that runs based on WordPress, the site URL and the Home entry from the WP options table in the database should be modified.
You can go to the Advanced Option and click Proceed to (your website name) to view your website.
If the Red Cross shown in Chrome is annoying you continuously, you need to for Chrome to accept your generated certificate.
Firstly, click the crossed-padlock icon. Then click the Certificate Information link. A popup will be shown, including all the information of the SSL Certificate assigned in the website. Drag-Drop the certificate icon to your Desktop.
A Keychain App will be shown when your bring this certificate if your running OS X.
Select ‘Always Trust’ and select your website certificate. Then click the [i] button to reveal the details of the certificate Trust level. Under the Trust tab, go to the option ‘When using this certificate’. Change the value to ‘Always Trust’. You will have to provide your password to update these changes.
That’s all. If you reopen the website in chrome, you should see the green padlock.
Congratulations, your SSL certificate is now trusted.
Open MAMP Pro.
- In Server Tab Make Sure Your HTTP Port is 80 and HTTPS Port is 443
- Click on Hosts Tab
- Click On Plus Arrow for add new host.
- Add 127.0.0.1 As Hostname
- Click SSL Enable
- Select Directory Where is your htdocs or websites folder
- Click on SSL Tab
- Create Self Signed Certificate By Button Below.
- Then it will ask for save location after save it will select certificate auto.
- Restart your MAMP Server.
Type : https with localhost then you can see result.