| Ludicrous Home > Manuals and HowTo's > Secure your Apache Web Server with a Certificate |
|
Secure your Apache Web Server with a Certificate
You can find a really good manual from Van on this matter.
Here I'll give just a small resume about the essential steps. [ Setup your own CA (Certificate Authority) ] [ Create the key ] [ Create the certificate ] [ Review the certificate ] [ Make a key and a certificate for the web server ] [ Move generated keys into Apache folders ] [ Configure the Apache web server ] [ Restart the web server ] [ Web Server Key Password ]
Setup your own CA (Certificate Authority)In order to run a secure (SSL/TLS encrypted) web server, you have to have a private key and a certificate for the server. Create the key[root]# openssl genrsa -des3 -out my-ca.key 2048 Create the certificate[root]# openssl req -new -x509 -days 3650 -key my-ca.key -out my-ca.crt Review the certificate[root]# openssl x509 -in my-ca.crt -text -noout
Make a key and a certificate for the web serverNow, we have to make an X.509 certificate and corresponding private key for the web server. Rather than creating a certificate directly, we will create a key and a certificate request, then "sign" the certificate request with the CA key we made previously.
[root]# openssl genrsa -des3 -out mars-server.key 1024 Please enter the following 'extra' attributes # openssl x509 -req -in mars-server.csr -out mars-server.crt -sha1 -CA my-ca.crt -CAkey my-ca.key -CAcreateserial -days 3650
Move generated keys into Apache foldersNow, we need to move the new keys and certs into the proper directories in the /etc/httpd hierarchy (assuming you have two folders named ssl.crt and ssl.key in /etc/httpd/conf): [root]# cp mars-server.crt /etc/httpd/conf/ssl.crt Configure the Apache web serverAll of our changes will be made in the /etc/httpd/conf.d/ssl.conf file. # Note that the FQDN and server hostname must go here - clients will not be able to connect, otherwise!
ServerName mars.vanemery.com:443
ServerAdmin webmaster@vanemery.com
# Here, I am allowing only "high" and "medium" security key lengths.
SSLCipherSuite HIGH:MEDIUM
# Here I am allowing SSLv3 and TLSv1, I am NOT allowing the old SSLv2.
SSLProtocol all -SSLv2
# Server Certificate:
SSLCertificateFile /etc/httpd/conf/ssl.crt/mars-server.crt
# Server Private Key:
SSLCertificateKeyFile /etc/httpd/conf/ssl.key/mars-server.key
# Server Certificate Chain:
SSLCertificateChainFile /etc/httpd/conf/ssl.crt/my-ca.crt
# Certificate Authority (CA):
SSLCACertificateFile /etc/httpd/conf/ssl.crt/my-ca.crt
# This is needed so that you can use auto-indexing for some directories in the
# /var/www/SSL directory branch. This can be handy if you would like to have
# a list of sensitive files for people to download.
<Directory "/var/www/SSL">
Options Indexes
AllowOverride None
Allow from from all
Order allow,deny
</Directory>
Restart the web server[root]# /etc/init.d/httpd start Note that you will have to enter the password for your server key in order to start the server. You will also have to do this during boot if you have httpd configured to start automatically (see below if you don't want this). Web Server Key PasswordIf you would like to make an insecure server key that will allow Apache to start automatically at boot time, then there is a way to do this. [root]# cd /etc/httpd/conf/ssl.key [ Setup your own CA (Certificate Authority) ] [ Create the key ] [ Create the certificate ] [ Review the certificate ] [ Make a key and a certificate for the web server ] [ Move generated keys into Apache folders ] [ Configure the Apache web server ] [ Restart the web server ] [ Web Server Key Password ]
|
| Document generated by Atlassian Confluence, last changed on may 03, 2007 by Sven Rieke |