Generating Self-Signed Certificate in XAMPP Win32 for Apache Web Server

posted in: Technical | 0

Below are the steps and additional information used to generate self-signed certificate and keys for Apache Web server in XAMPP for Win32 platform.

#Step 1: Generate a Private Key
C:\xampp\apache\bin>openssl genrsa -des3 -out server.key 1024     
Loading 'screen' into random state - done
Generating RSA private key, 1024 bit long modulus
.........................................................++++++
..........................................++++++
e is 65537 (0x10001)
Enter pass phrase for server.key: xxxxxxxx
Verifying - Enter pass phrase for server.key: xxxxxxxx

#Step 2: Generate a CSR (Certificate Signing Request)
C:\xampp\apache\bin>openssl req -new -key server.key -config "C:\xampp\php\extras\openssl\openssl.cnf" -out server.csr
Enter pass phrase for server.key: xxxxxxxx
Loading 'screen' into random state - done
You are about to be asked to enter information that will be incorporated into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:
State or Province Name (full name) [Some-State]:Western Australia
Locality Name (eg, city) []:Perth
Organization Name (eg, company) [Internet Widgits Pty Ltd]:LatunyJ Corporation
Organizational Unit Name (eg, section) []:Information Technology
Common Name (eg, YOUR name) []:localhost
Email Address []:latunyj@hotmail.com

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []: xxxxxxxx
An optional company name []:LatunyJ Corporation

#Step 3: Remove Passphrase from Key
C:\xampp\apache\bin>copy server.key server.key.org
1 file(s) copied.

C:\xampp\apache\bin>openssl rsa -in server.key.org -out server.key
Enter pass phrase for server.key.org:
writing RSA key

#Step 4: Generating a Self-Signed Certificate
C:\xampp\apache\bin>openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
Loading 'screen' into random state - done
Signature ok
subject=/C=AU/ST=Western Australia/L=Perth/O=LatunyJ Corporation/OU=Information
Technology/CN=localhost/emailAddress=latunyj@hotmail.com
Getting Private key

#Step 5: Installing the Private Key and Certificate
C:\xampp\apache\bin>copy server.crt c:\xampp\apache\conf\ssl.crt
C:\xampp\apache\bin>copy server.key c:\xampp\apache\conf\ssl.key

#Step 6: Restart Apache and Test 
Restart Apache and test browsing to https://yoursite.com

References:
http://www.akadia.com/services/ssh_test_certificate.html
http://www.opencodez.com/apache/ssl-certificate-and-install-in-xampp.htm