Step by step tutorial how to create working self signed SSL certificate for XAMPP apache server on Windows (Even working in chrome version > 58)
You can download OpenSSL binary here. Just extract contents in some directory - I put mine in C:/OpenSSL Than add OpenSSL executable in your PATH. How to add folders to PATH in windows?
Make sure that there is following line and that is not commented (# in front) in {your_xampp_installation_path}/XAMPP/apache/conf/httpd.conf:
LoadModule ssl_module modules/mod_ssl.so
Created certificate will be working for local domain example.test. Make sure to change values to your own virtual host name.
Add your virtual host config in {your_xampp_installation_path}/XAMPP/apache/conf/extra/httpd-vhosts.conf. Make sure to restart your apache server afterwards.
<VirtualHost *:443>
DocumentRoot "{your_xampp_installation_path}/XAMPP/htdocs/{your_host_root}"
ServerName www.example.test
ServerAlias example.test
SSLEngine On
SSLCertificateFile "{your_xampp_installation_path}/XAMPP/apache/conf/ssl.crt/example.crt"
SSLCertificateKeyFile "{your_xampp_installation_path}/XAMPP/apache/conf/ssl.key/example.key"
<Directory "{your_xampp_installation_path}/XAMPP/htdocs/{your_host_root}">
Options All
AllowOverride All
order allow,deny
allow from all
</Directory>
</VirtualHost>
Create new .bat script in folder {your_xampp_installation_path}/XAMPP/apache/conf with this code. Then run this script by duble clicking on it.
@echo off
REM IN YOUR SSL FOLDER, SAVE THIS FILE AS: makeCERT.bat
REM AT COMMAND LINE IN YOUR SSL FOLDER, RUN: makecert
REM IT WILL CREATE THESE FILES: example.cnf, example.crt, example.key
REM IMPORT THE .crt FILE INTO CHROME Trusted Root Certification Authorities
REM REMEMBER TO RESTART APACHE OR NGINX AFTER YOU CONFIGURE FOR THESE FILES
REM PLEASE UPDATE THE FOLLOWING VARIABLES FOR YOUR NEEDS.
SET HOSTNAME=example
SET DOT=test
SET COUNTRY=SI
SET STATE=Slovenia
SET CITY=Ljubljana
SET ORGANIZATION=IT
SET ORGANIZATION_UNIT=IT Department
SET EMAIL=webmaster@%HOSTNAME%.%DOT%
(
echo [req]
echo default_bits = 2048
echo prompt = no
echo default_md = sha256
echo x509_extensions = v3_req
echo distinguished_name = dn
echo:
echo [dn]
echo C = %COUNTRY%
echo ST = %STATE%
echo L = %CITY%
echo O = %ORGANIZATION%
echo OU = %ORGANIZATION_UNIT%
echo emailAddress = %EMAIL%
echo CN = %HOSTNAME%.%DOT%
echo:
echo [v3_req]
echo subjectAltName = @alt_names
echo:
echo [alt_names]
echo DNS.1 = *.%HOSTNAME%.%DOT%
echo DNS.2 = %HOSTNAME%.%DOT%
)>%HOSTNAME%.cnf
openssl req -new -x509 -newkey rsa:2048 -sha256 -nodes -keyout %HOSTNAME%.key -days 3560 -out %HOSTNAME%.crt -config %HOSTNAME%.cnf
Add certificate to chrome trusted authorities. Go to Settings -> Manage Certificates -> Import Than select generated certificate in previous step. Should be located in {your_xampp_installation_path}/XAMPP/apache/conf/example.crt In the field "Place all certificates in the following store:" select "Trusted root certification authorities".
Visit https://example.test and celebrate the green lock in browser's address bar :D