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

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 (0×10001)
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) []:latunyj.no-ip.org
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=latunyj.no-ip.org/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

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

Advertisements

4 thoughts on “Generating Self-Signed Certificate in XAMPP Win32 for Apache Web Server

  1. Hi I tried this . But I got the following error

    C:\xampp\apache\bin>openssl req -new -key server.key -config “C:\xampp\php\extra
    s\openssl\openssl.cnf” -out server.csr
    WARNING: can’t open config file: /usr/local/ssl/openssl.cnf
    error on line -1 of ôC:\xampp\php\extras\openssl\openssl.cnfö
    4688:error:0200107B:system library:fopen:Unknown error:.\crypto\bio\bss_file.c:1
    69:fopen(‘ôC:\xampp\php\extras\openssl\openssl.cnfö’,’rb’)
    4688:error:2006D002:BIO routines:BIO_new_file:system lib:.\crypto\bio\bss_file.c
    :174:
    4688:error:0E078002:configuration file routines:DEF_LOAD:system lib:.\crypto\con
    f\conf_def.c:199:

    Then I had to copy the C:\xampp\php\extras\openssl\openssl.cnf into the currnet folder to make it work

    Thanks

    • You need to set up your PATH-Variable. This can look like this: set OPENSSL_CONF=c:\[PATH TO YOUR OPENSSL DIRECTORY]\bin\openssl.cfg

  2. Pingback: Không khởi động được Xampp do lỗi SSL | Blog Hoangweb.com

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s