Install SSL Certificate on WAMP

SSL was developed by Netscape to enable secure communication when clients and servers exchange sensitive or private information. Learn in this post how to create and set up an SSL certificate on WAMP.

Install SSL Certificate on WAMP

What is an SSL Certificate? A Brief Overview

An SSL (Secure Socket Layer) on WAMP helps to establish a secure communication connection by enabling HTTPS on the local web server. So we can securely connect to the server rather than using the HTTP protocol. The following is a general overview of how an SSL certificate works.

  • Whenever a client tries to establish a secure connection with a server (SSL enabled),  it sends all the encryption methods it can support.
  • The server will then choose the strongest encryption method both ends can support. The server will send back a certificate with a public encrypted key. This certificate should be signed by a known CA Certificate Authority to be credible.
  • The client then receives the certificate along with the public key and generates a new session key encrypted with the public key sent by the server. If the client can not match the key sent by the server, it will use OCSP (Online Certificate Status Protocol) to validate the certificate.
  • After creating a new session key, the client sends this session key to the server to establish a successful handshake.

How to Set up an SSL Certificate on WAMP

Follow these simple steps to install SSL on Windows WAMP:

  1. Generate an SSL private key and remove the passphrase from it.
  2. Generate an SSL certificate.
  3. Move the SSL key and certificate to the desired location.
  4. Configure http-ssl.conf.
  5. Configure httpd.conf.

Step 1. Generate SSL Private Key

  • The first step to take is to open the command prompt and go to this location C:\wamp\bin\apache\apache2.4.9\bin and open openssl.exe.
  • Create a key for our certificate using the following command.
    genrsa -des3 -out domain.key 2048
  • After pressing the Enter key, it will ask to enter a pass phrase. You can type anything in here, but you have to remember it.
  • Next, let's remove the passphrase from our key. To do that, type the following command and press Enter.
    rsa -in domain.key -out domain.key

Step 2. Generate SSL Certificate

  • Now that we have removed the passphrase from our key, it is time to create our self-signed certificate, and to do that, type the following command and press Enter.
    req -new -x509 -nodes -sha1 -key domain.key -out domain.crt 
    -days 365 -config C:\wamp\bin\apache\apache2.4.9\conf\openssl.cnf
  • It will ask to enter information about the certificate, like country name, province, company name, company unit, and email address.

Step 3. Move The SSL Key and SSL Certificate

  • You will see two files, "domain.key" and "domain.crt"  generated in C:\wamp\bin\apache\apache2.4.9\bin. Copy them and go to C:\wamp and create a folder "ssl" and paste these two files in this folder.
  • Now, create another folder "logs" in the same location, where we will store all our transaction logs in this folder.

Step 4. Configure http-ssl.conf

  • Now that we have created our certificate files and placed them in the right location its time to configure http-ssl. Go to location C:\wamp\bin\apache\apache2.4.9\conf and open http-ssl.conf file.
  • Find these lines:
    SSLSessionCache "shmcb:C:/Program Files/Apache Software Foundation/Apache2.2/logs/ssl_scache(512000)"
  • And replace with:
    SSLSessionCache "shmcb:C:/wamp/logs/ssl_scache(512000)"
  • Find these lines :
    DocumentRoot "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs"
    ServerName localhost:443
    ServerAdmin admin@localhost
    ErrorLog "C:/Program Files/Apache Software Foundation/Apache2.2/logs/error_log"
    TransferLog "C:/Program Files/Apache Software Foundation/Apache2.2/logs/access_log"
  • And replace with:
    DocumentRoot "C:/wamp/www"
    ServerName localhost:443
    ServerAdmin admin@localhost
    ErrorLog "C:/wamp/logs/ssl_error.log"
    TransferLog "C:/wamp/logs/ssl_access.log"
  • Next, find this line to set our certificate:
    SSLCertificateFile "C:/Program Files/Apache Software Foundation/Apache2.2/conf/server.crt"
  • And Replace with:
    SSLCertificateFile "C:/wamp/ssl/domain.crt"
  • Next, find this line to set our key file:
    SSLCertificateKeyFile "C:/Program Files/Apache Software Foundation/Apache2.2/conf/server.key"
  • And replace with:
    SSLCertificateKeyFile "C:/wamp/ssl/domain.key"
  • Next, find this line:
    CustomLog "C:/Apache24/logs/ssl_request.log" \
              "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
  • And replace with:
    CustomLog "C:/wamp/logs/ssl_request.log" \
              "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b" 

Step 5. Configure httpd.conf

  • The next step is to configure our http.conf go to this location C:\wamp\bin\apache\apache2.4.9\confand open httpd.conf.
  • Find these lines and remove the comment "#" at the beginning of each line
    #LoadModule ssl_module modules/mod_ssl.so
    #LoadModule socache_shmcb_module modules/mod_socache_shmcb.so
    #Include conf/extra/httpd-ssl.conf
  • All done! Restart the WAMP server and open the URL https://localhost in a browser.
NOTE: So far it should be working, still if you face any issue, go to this location C:\wamp\bin\apache\apache2.4.9\bin and copy libeay32.dll and ssleay32.dll and paste them into C:\Windows\System32