In my previous blog post I have described how to make your own SSL certificates using OpenSSL. Now here I'm going to describe how to install SSL certificates on Apache. ("Install SSL certificates on Apache" stated here actually means copying the files somewhere and configuring Apache to make use of them)
Before giong into the 'How to', let me explain how does it work. The two application layer protocols HTTP and HTTPS work on two separate ports; they do not (actually can not) use the same port. The default port for HTTP is port 80 and for HTTPS it is port 443. What we need to do is configure Apache to keep the port 443 open and to use the certificate we have just made. What we need are a text editor, RSA key file (localhost.key from my example) which we have made, and the corresponding certificate file (localhost.crt in my example).
The main configuration settings of Apache HTTP server are stored in a text file named httpd.conf. One good habit is to create a backup before you edit any configuration file, so if you have done any mistake you can easily restore the original configuration. So make a copy of the file somewhere else and open the original using your preferred text editor for editing.
Note:
- In XAMPP for Linux, this file can be found at $PROGRAM_INSTALLATION_DIR/lampp/etc/httpd.conf
- In Apache for Windows, this file can be found at $PROGRAM_INSTALLATION_DIR\xampp\apache\conf\httpd.conf
- If you can not find this file, use your operating system's file search utility to locate the file.
Now continue with these easy and simple steps.
- Find out where the configuration is located
- Enable SSL bylocating the .key and .crt files
- Restart Apache
Find out where the configuration is located
Before enabling SSL, click here to check whether SSL is already enabled. If you get the "Server not found!" error, then SSL is not enabled. Otherwise you can skip this step.
In httpd.conf, search for the following line with your text editor's search capability. (_default_ should be your hostname unless you have specified one before)
If it cannot be found, search for something that looks like the following two lines. (The second line contains what we need). If it can be found, go to the next step.
# Secure (SSL/TLS) connections
Include conf/extra/httpd-ssl.conf
If it cannot be found, then go to the next step. If it can be found, open the file specified at 'Include', with your text editor. In this case it is conf/extra/httpd-ssl.conf . There should be the virtualhost we are looking for.
Enable SSL bylocating the .key and .crt files
First copy the two files localhost.crt and localhost.key into conf/ssl.crt/ .
If you were not able to find the
SSLEngine on
SSLCertificateFile conf/ssl.crt/localhost.crt
SSLCertificateKeyFile conf/ssl.key/localhost.key
BrowserMatch ".*MSIE.*" \
nokeepalive ssl-unclean-shutdown \
downgrade-1.0 force-response-1.0
If you were able to find the
Save and close the file after you have finished editing.
Restart Apache
Now, the final step is to restart Apache. The most simple way is, go to XAMPP Control Panel (it is available on both Linux and Windows), and then Stop it and then Start. If you have done everything correctly, Apache should successfully restart and you should be able to visit this page.
Viola! You have done it!! If you need further clarifications or if you have any questions regarding this article, please leave a comment below.
Thank you for reading!
source
http://www.ucsclodge.lk/content/how-install-your-ssl-certificate-apache
No comments:
Post a Comment