Enable SSL for apache and create self signed certificate (CentOS 6.5)

First, install mod_ssl and openssl. All of the commands will need to be run as root or su

yum install mod_ssl openssl

Now we generate the self signed certificate

openssl genrsa -out ca.key 2048 
openssl req -new -key ca.key -out ca.csr
openssl x509 -req -days 365 -in ca.csr -signkey ca.key -out ca.crt
cp ca.crt /etc/pki/tls/certs
cp ca.key /etc/pki/tls/private/ca.key
cp ca.csr /etc/pki/tls/private/ca.csr

Now we need to update apache to use ssl

vi +/SSLCertificateFile /etc/httpd/conf.d/ssl.conf

Make sure the SSL key paths are correct, if you’ve saved them to the same location as above the lines would need to be

SSLCertificateFile /etc/pki/tls/certs/ca.crt

and just below that line

SSLCertificateKeyFile /etc/pki/tls/private/ca.key

Save and quit vi with :w:q

Now restart apache

/etc/init.d/httpd restart

Don’t forget to add port 443 through your firewall and router!

Print Friendly, PDF & Email

More Like This


Categories


CentOS Linux Web Hosting
  • Post a comment