Add Ssl To Xampp

Posted on by admin

Jun 12, 2019 If you need to add a Free SSL to your XAMPP install (windows), this is a small tutorial on how to do this: First, you need to make sure your firewall resolves port 80 and 443. Setup the appropriate rules in your router for this. Enable port 80 and 443 to your servers IP and have TCP en UPD rules both enabled.

  • Double click on localhost.crt on Finder. Select Keychain: System then click Add. Find & double click on localhost cert in Keychain Access. Expand Trust, select When using this certificates: Always Trust. Close the window and click Update Settings. Config SSL in XAMPP virtual host. Open /Applications/XAMPP/xamppfiles/etc/extra/httpd-vhosts.conf. Update your config.
  • Using file explorer. The path to the configuration file depends on the folder you chose during setup of XAMPP control panel. You can see the folder of installation when opening the panel: The directory specified should contain the Apache folder. From there, navigate to the conf folder extra folder httpd-ssl.conf file. You can open the file with any text editor.
  • The previous lines will enable the SSL in your project. Note that the paths are relative, with a normal installed xampp distribution it should work, if it doesn't work try changing it to the absolute path. They're normally located inside the xampp/apache/conf/ssl.key/server.key and xampp/apache/conf/ssl.crt/server.crt.

Updated: 4/12/2020

Setting up an SSL certificate for XAMPP is pretty straight forward, but it won’t completely work if you are trying to use a private, local domain on your own computer. This is mostly caused by the certificates not being issues by a Certificate Authority, but rather it’s a self-signed certificate.

You can be your own Certificate Authority easy enough, but everything has to be typed correctly at the command prompt or it can fail, leaving you scratching your head. Completing a CA cert and SSL cert process may complete and the certificate is still not verifiable because something was not quite right in the configuration.

Add ssl to xampp for windows

Another thing that I discovered is that copying a command from the Internet may not work correctly due to some hidden chars in the string.

Once you are successful at generating a root CA cert and an SSL cert, it’s a matter of setting up the XAMPP Apache configuration. Then you will have to edit the root CA cert that CURL uses so that it can verify you SSL cert. The PHP CURL configuration needs to point to this file and if you use WordPress, this root CA cert needs to be added to the WordPress includes as well.

Let’s begin.

First install XAMPP and get it running so that you can access it’s dashboard in your browser via http.

Next, we want to add the path to OpenSSL to our path system variable so we don’t have to be in the xampp/apache/bin directory to run it. I assume you know how to add a directory to you Windows 10 system path already. If not, simply run SystemPropertiesAdvanced command, click the “Environment Variables” button and add the path to the end of the “Path” system variable (e.g. C:/xampp/apache/bin).

Rapid Environment Editor is a great tool to edit your system path with.

Note, Windows 10 comes with CURL, so if you don’t add xampp/apache/bin to your path system variable, you will be running the Windows installation of CURL and not the one included with XAMMP. Place the path to the xampp/apache/bin directory before %SystemRoot%system32.

Next, we add a crt/dev.local directory under Apache and work inside this directory.

Run Windows cmd.exe.

Now you are going to make yourself a Certificate Authority.

Now you have a CA private key and CA certificate.

Next we will use these to generate an SSL private key and cert.

Make a file named csr.ext with the following entries. This is important to have an “alt_name” so it will work in Chrome. Add localhost and so it will work with those too.

How To Add Ssl Certificate To Xampp Server

The next batch of commends is a two line command made to enter after executing openssl. You will get a prompt to enter commands and you can continue on the next line with a “” at the end of each line.

Now you will need to tell Windows about your CA certificate.

Run the Windows Cert Manager certmgr. Choose Trusted Root Certification Authorities, right click on Certificates>>All Tasks>>Import… and import your CA Certificate (EWWCA.pem).

Click Next.

Choose the file. You will need to choose “All Files (*.*)” in the file chooser dialog to show your pem file or type it in directly.

Place all certificates in the following store: Trusted Root Certificate Authorities.

Click Finish.

You will get a “The import was successful.” message and then you will be able to browse the root certificates and see the one you just added.

Now all you need to do is create virtual hosts in Apache and point to the new SSL Certificate and Key that you made.

Add ssl to xampp for windows

Open the Apache httpd-xampp.conf file and add these entries:

Now, https should work in Chrome and Edge, but not in Firefox. If it doesn’t work, restart your browser or restart your computer.

You will need to import your CA certificate directly into Firefox’s CA store.

Run Firefox and go to Options>>Privacy & Security>>Security Devices and click on the “View Certificates…” button. On the next dialog box, click on the Authorities tab and click the “Import…” button.

On the next dialog box, check the 2 boxes and click OK.

Now https should work in Firefox. If not, restart Firefox or restart the computer.

Now check your PHP.ini file and enable extension=curl and point curl.cainfo and openssl.cafile both to C:xamppapachebincurl-ca-bundle.crt. CURL will work for PHP scripts now, unless the script uses it’s own CA bundle file. (See below how to enable your CA cert in WordPress.)

At this point, CURL included with XAMPP will work if you access https sites on the Internet, but it will fail if you access a site on dev.localhost because CURL uses curl-ca-bundle.crt file for it’s CA certs. Your new CA cert is not in this file, so you will need to open up curl-ca-bundle.crt and your pem file (EWWCA.pem) in a text editor.

Copy everything in the pem file.

Open up the curl-ca-bundle.csr file located in xampp/apache/bin and scroll down to the very bottom of the file and paste in your CA cert. Ensure there are no spaces or new lines at the end. As shown in the screenshot above, you can also add a title to the cert so you know what it is.

Save the file and now CURL will work https on dev.localhost from the command line (cmd.exe).

Xampp Ssl Setup

To enable CURL to work in WordPress, after you have added your CA cert to it as per the previous instructions, copy the curl-ca-bundle.csr file to the /wp-includes/certificates folder. Then rename ca-bundle.csr to ca-bundle.old and change curl-ca-bundle.csr filename to ca-bundle.scr.

Add Ssl To Xampp Download

CURL should now work with any WordPress plugins that access https://dev.localhost URLs.

Enable SSL virtual host in apache2 xampp

SSL set up on Apache needs a ssl enabled virtual host configuration with matching certificate and private key.

In more details let’s say we are looking to configure, for testing purposes, a local domain with SSL encryption. For the purpose of the exercise we are going to run mydomain as the custom domain where we are going to run our SSL enabled virtual host. Lets look at the configuration in apache. Specifically in XAMPP the configuration for virtual hosts can be made under xampp/apache/conf/extra/http-vhosts.conf .

Some of the steps below are not essential for SSL configuration but overall they can help you create a custom configuration for you local development project

Add Ssl To Xampp
    1. STEP 1 : Add our custom domain to the hosts configuration
      in the hosts configuration (Windows C:WindowsSystem32driversetchosts or /etc/hosts in linux – this might change depending on distros) add a new domain to map the loopback ip address. This will allow your browser to request the mydomain site to the machine running on your loopback address, thus your local host. mydomain

      Please add this line to the hosts file using an administrator/root account and make sure the changes are saved correctly

      At this point if you are already running XAMPP with the default configuration visiting http://mydomain/ should redirect you to http://mydomain/xampp/ the main XAMPP control page

    2. STEP 2 : add standard virtual domain configuration in apache for “mydomain”
      Under xamppapacheconfextra open the file httpd-vhosts.conf and lets add a new virtual host configuration. Note, I have created another mydomain folder under htdocs in the XAMPP folder and it is being used as the document root in our configuration

After restarting apache visit http://mydomain/ again. You should see an empty index page displayed by default by apache indexing service. Lets put an hello world index.htm HTML page for testing purposes in the mydomain folder

Add Ssl To Xampp Software

  1. STEP 3 – Create certificates, in our case self signed. For production you might need a certificate signed by an authority to make sure it will be compatible with all browsers in the market
    1. Generate primary key – openssl genrsa -des3 -out mydomain.key 1024 – it will ask to enter a password for the key
    2. Generate a CSR (Certificate Signing Request) – openssl req -new -key mydomain.key -out mydomain.csr – This steps requests a few pieaces of information, the most important being the Common Name where the fully qualified value of your domain name needs to be included. In this example we are using “mydomain” as the value
    3. Remove passphrase from private key (to avoid the need to enter the password everytime apache is started) –
      cp mydomain.key mydomain.key.old
      openssl rsa -in mydomain.key.old -out mydomain.key

      Now mydomain.key is free of passwords.
    4. Generate self-signed certificate – openssl x509 -req -in mydomain.csr -signkey mydomain.key -out mydomain.crt (if you want to limit the validity of this certificate you can use for instance -days 365 to make it valid for 365 days)
  2. STEP 4 – Enable Mod SSL in apache – in xamp/apache/conf/httpd.conf enable/uncomment the mod_ssl module
    Search and uncomment this line
    LoadModule ssl_module modules/
  3. STEP 5 – Install and test certificate in a virtual host configuration
    In step 2 we created a virtual host for our mydomain service on port 80. Now we have created certificates and we are ready to include a new virtual host to allow our domain to run on SSL enabled mode. After the virtual host configuration created in step 2 we add another virtual host mapping to enable the service on port 443 (default for SSL) as follows:

After including the above in our apache configuration the full directives/configuration statements included for the mydomain virtual host should look like this

Now dont forget to restart and test both http://mydomain and https://mydomain.

When accessing the HTTPS version of the site the browser will show an alert security because the certificate we are using for testing purposes is “self-signed”. For a production service/domain/site you need to request the certificate from an SSL authority like Verisign.

Xampp Https

The above is provided with no guarantee whatsoever, so please use at your own responsibility. For further comments or help you can try to contact me using he contact us link on the menu of the site.

Setup Ssl Xampp

Also for further details on creation of SSL certificates you can take a look at