This tutorial will demonstrate how to install SSL certificate in Windows localhost WAMP server.
Install SSL on windows localhost WAMP HTTP & SSL HTTPS
Lot many times our production servers are installed with SSL certificates and our local development machines uses normal http, and this makes our development system different from our production one. And as a developer we always like to have an exact environment like our production system.
If you are not able to convert WAMP server icon to green, you can check this video.
So here’s the guide how to install self signed SSL certificate on the local WAMP installation and use Https communication with your local WAMP.
Resources used in tutorial:
File with all commands | Download |
Here are the things we are going to do
- Download & install WAMP (Assuming that WAMP is installed in C: drive)
- Download & install OpenSSL
- Configure WAMP to use HTTP + SSL = HTTPS
If you want to run multiple WordPress installations on single server with sub-domain, you can check this video on Apache 2 sub domain mapping.
Watch the video tutorial to know about the detailed step by step procedure.
Ste by step process for making HTTPS enabled WAMP | HTTP+SSL=HTTPS
Step 1:
Download & install WAMP (Assuming that WAMP is installed in C: drive)
Step 2:
Download & install OpenSSL
Step 3:
Configure WAMP to use HTTP+SSL=HTTPS
Step 4:
1 2 |
Path to openssl.exe : C:\wamp\bin\apache\apache2.4.9\bin\openssl.exe Path to openssl.cnf : C:\wamp\bin\apache\apache2.4.9\conf\openssl.cnf |
Step 5:
CMD in Path to openssl.exe :::
1 2 3 |
openssl genrsa -aes256 -out private.key 2048 openssl rsa -in private.key -out private.key openssl req -new -x509 -nodes -sha1 -key private.key -out certificate.crt -days 36500 -config C:\wamp\bin\apache\apache2.4.9\conf\openssl.cnf |
Now copy the privateKey & certificate into folder
Step 6:
Open httpd.conf & uncomment following
1 2 3 |
LoadModule ssl_module modules/mod_ssl.so Include conf/extra/httpd-ssl.conf LoadModule socache_shmcb_module modules/mod_socache_shmcb.so |
Open php.ini (wampbinphpphp5.5.12php.ini)
1 |
extension=php_openssl.dll |
Step 7:
Edit C:/wamp/bin/apache/apache x.x.x/conf/extra/httpd-ssl.conf
1 2 3 4 5 6 7 8 9 10 |
<VirtualHost _default_:443> (Below this line check following parameters) ------------------- DocumentRoot "C:/wamp/www" ServerName localhost:443 ServerAdmin admin@example.com ErrorLog "C:/wamp/bin/apache/apache2.4.9/logs/ssl_error.log" TransferLog "C:/wamp/bin/apache/apache2.4.9/logs/ssl_access.log" SSLCertificateFile "C:/wamp/bin/apache/apache2.4.9/conf/key/certificate.crt" SSLCertificateKeyFile "C:/wamp/bin/apache/apache2.4.9/conf/key/private.key" ------------------- |
Step 8
Now check the syntax of file using below command.
1 |
httpd -t (To check the validity of file) |
Want to buy me a beer?
[wpedon id=2805]
Hi. I would like some help regarding this ssl cert for academic purpose. I followed everything in your tutorial but when I execute the step: httpd -t (in cmd), I got an error and cannot open the localhost with https. The error is as below:
[core:warn] [pid 5040:tid 196] AH00111: Config variable ${SRVROOT} is not defined
I’ve been working on this one problem for days and still can’t seem to solve it. Could you help me with this problem? Thank you.
Step: 1
You need to Define the variable SRVROOT in httpd.conf file.
You can refer to this question on how to define variable in httpd.conf file:
https://stackoverflow.com/questions/6569080/how-to-define-a-variable-in-apaches-httpd-conf-file
Thanks for the tutorial. Is ‘localhost’ a FQDN? I also develop sites on localhost and update my HOSTS file so the domain is resolves at my IP (e.g. 127.0.0.1 MYDOMAIN.COM), will these SSL instructions work for instances like this too?
Hello once I enter genrsa -aes256 -out private.key 2048 it won’t let me type anything and if i bypass to the next cmd i get errors
Hi RJ,
Did you use –
openssl genrsa -aes256 -out private.key 2048
And if command is running, you should wait for some time for it to finish.
Just wanted to say I really appreciated your clear and concise instructions on this – thanks 🙂
Really glad that could help. 🙂
i have install certificate same above process but certificate invalid showing . its https work but Lock sign is not showing.
That’s normal because you are using self signed certificate. When you install on your production server, you will need to use ca verified certificate, which will not give any warning.
there is no way you can use verified certificate on localhost.
what if we have XAMPP
I Follow all instructions till the end but in the last my wamp server could not run.
Kindly help me to solve this error.
In the log file showing this error:
[Wed Feb 05 12:47:23.406487 2020] [ssl:emerg] [pid 4108:tid 420] AH02564: Failed to configure encrypted (?) private key localhost:443:0, check C:/wamp64/bin/apache/apache2.4.41/conf/Key/certificate.crt
[Wed Feb 05 12:47:23.406487 2020] [ssl:emerg] [pid 4108:tid 420] SSL Library Error: error:0D0680A8:asn1 encoding routines:asn1_check_tlen:wrong tag
[Wed Feb 05 12:47:23.406487 2020] [ssl:emerg] [pid 4108:tid 420] SSL Library Error: error:0D08303A:asn1 encoding routines:asn1_template_noexp_d2i:nested asn1 error
[Wed Feb 05 12:47:23.406487 2020] [ssl:emerg] [pid 4108:tid 420] SSL Library Error: error:0D0680A8:asn1 encoding routines:asn1_check_tlen:wrong tag
[Wed Feb 05 12:47:23.406487 2020] [ssl:emerg] [pid 4108:tid 420] SSL Library Error: error:0D07803A:asn1 encoding routines:asn1_item_embed_d2i:nested asn1 error (Type=RSAPrivateKey)
[Wed Feb 05 12:47:23.406487 2020] [ssl:emerg] [pid 4108:tid 420] SSL Library Error: error:04093004:rsa routines:old_rsa_priv_decode:RSA lib
[Wed Feb 05 12:47:23.406487 2020] [ssl:emerg] [pid 4108:tid 420] SSL Library Error: error:0D0680A8:asn1 encoding routines:asn1_check_tlen:wrong tag
[Wed Feb 05 12:47:23.406487 2020] [ssl:emerg] [pid 4108:tid 420] SSL Library Error: error:0D07803A:asn1 encoding routines:asn1_item_embed_d2i:nested asn1 error (Type=PKCS8_PRIV_KEY_INFO)
Kindly reply as soon as possible.
(OS 3)The system cannot find the path specified. : AH02297: Cannot access directory ‘C:/wamp/bin/apache/apache2.4.41/logs/’ for log file ‘C:/wamp/bin/apache/apache2.4.41/logs/ssl_access.log’ defined at C:/WebServer/bin/apache/apache2.4.41/conf/extra/httpd-ssl.conf:288
AH00014: Configuration check failed
i need help
msg me on email pls
pass phrase for private.key is ??? pls (i put this kneap) but it does not work
facing error while httpd -t command running
(OS 11001)No such host is known
I followed your steps, but when I try to start the wamp server it fails with an error 1, and in the Windows Event logs, shows ‘illegal function’.
My server is a Win 2019 server running Wamp64/Apache2.4.46/SQL/Python… Apache was working fine serving content on port 80 before I tried to enable SSL/Https…
Httpd-t says no syntax errors.
1) I see a lot of noise about FQDN versus localhost when creating the certificate. What is the reality here? Do I need the name of the machine, the DNS name, localhost or …?
2) Is there a way to debug this process? The Apache server doesn’t launch so its logs aren’t updated and the windows system logs are useless. Any ideas?
Thanks!