Google Search

Google

What is the most suitable distro to use as a server?

Visit Us!

Google Groups
Kuantan Linux User Group
Visit this group

Threat Resource Center | Trend Micro

Friday, October 5, 2007

Create A Self-signed SSL Certificate in XAMPP

I have added a plugins for my webmail (Squirrelmail). 
It is Secure Login plugins. 
This plugins enables a secure HTTPS/SSL-encrypted connection
for my SquirrelMail login page. So, it can secure my email access. 
As I'm using Apache in XAMPP, the generated SSL certificate are using the default setting.
When I view the certificate, it show's a default XAMPP Apache setting like below :


Issued To
Common Name (CN)           localhost
Organization (O)               Apache Friends
Organization Unit (OU)      
Serial Number                   00

Issued By
Common Name (CN)           localhost
Organization (O)               Apache Friends
Organization Unit (OU)     


So, to create my own self-signed SSL certificate, I need to edit the certain file make a few tuning. So that, the certificate will be no longer using a default XAMPP setting.

1. Open a terminal/console at local or do it remotely through SSH access


2. The first thing that need to do is, create a RSA Private Key by using the below command.

[root@mybox ~]#openssl genrsa -des3 -out server.key 1024

Generating RSA private key, 1024 bit long modulus
.........................................................++++++
........++++++
e is 65537 (0x10001)
Enter PEM pass phrase: enter the desired pass phrase
Verifying password - Enter PEM pass phrase: same as a above


3. The next step is to create a Certificate Signing Request (CSR). CSR is a message sent from an applicant to a certificate authority in order to apply for a digital identity certificate. User will be prompt to enter an information that related to CSR certificate. To create a CSR, enter the below command.

[root@mybox ~]#openssl req -new -key server.key -out server.csr

Country Name (2 letter code) [GB]:type your 2 letter country code
State or Province Name (full name) [Berkshire]:
type your state or province name
Locality Name (eg, city) [Newbury]:
type your city name
Organization Name (eg, company) [My Company Ltd]:type your company name

Organizational Unit Name (eg, section) []:type your department
Common Name (eg, your name or your server's hostname) []:type your server hostname
Email Address []:
type your email address
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
type your password
An optional company name []:
type your company name


4. The next step is to remove the passphrase key. It is because if you enable the passphrase, Apache will ask for the pass-phrase each time the web server is started. It will be a problem if the server is restarted as the user always need to type the passphrase. The below command will remove the passphrase.

[root@mybox ~]#cp server.key server.key.org
[root@mybox ~]#openssl rsa -in server.key.org -out server.key


5. To generating a Self-Signed Certificate, enter the below command. As this certificate is not verified by Certificate Authority such as Thawte or Verisign, your browser will notice an error inform you that the signing certificate authority is unknown and not trusted. Bear in mind that this is self-signed certificate. So, you should ignore that error message.

[root@mybox ~]#openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt


6. Installing the Private Key and Certificate is simple. All you need to do is to know where are your XAMPP Apache directory. I assume that, we are using the default XAMPP directory, /opt/lampp. So, copy the two below files, ssl.crt and ssl.key to the XAMPP directory.

[root@mybox ~]#cp server.crt /opt/lampp/etc/ssl.crt
[root@mybox ~]#cp server.key /opt/lampp/etc/ssl.key/server.key

When you are being asked to overwritten the file, just type yes and hit Enter.


7.
Restart Apache and test to access your site. Check the certificate and make sure the information that you have insert is correct.


8.
Finish! Your configuration is done. Good luck :-)


10 comments:

drews77 said...

I'm running the Windows version of Xampp. Do you have instructions for accessing the console? Standard Windows console does not recoginize the commands. Thanks

Jafar Rahmati said...

That is very simple!
1. The openssl command stands in the folder apache of xampp.
2. In step 4 use copy instead of cp
3. In step 6 you need to place the private key and the certificate in to the right location:
- [xampppath]\apache\conf\ssl.crt
- [xampppath]\apache\conf\ssl.key

bellafuente said...

Nice tutorial, as you mentioned, there is still the popup about "not trusted.. blabla" but i could avoid the other warnings about "this certificate belongs to localhost". thx again

Anonymous said...

Thanks!

Plat said...

U know that hotlinking images, like the one U do of open source, is a criminal who's penalty in some countries might be 10,000US$ per link? I suggest U unlink that image.

Wildcard SSL Certificates said...

Very informative blog, that is good from the website point of view. I am greatfull to read it.

RapidSSL said...

it's really informative resource for self signing certificate. Thank you so much for sharing it with US. Let me allow to share this on our SSL education blog!

imshahmemyselfandi said...

RapidSSL, thank you very much for visiting my blog. Please feel free to sharing my blog :)

Anonymous said...

This OpenSSL tutorial is very easy !
Really thanks!

Anonymous said...

very helpful instruction!
thank u very much :)

Linux News Of The Day!

Powered By
widgetmate.com
Sponsored By
Credit Card Forum