Configure self signed SSL certificate

Configure self signed SSl certificate for Apache running on CentOS 6.x

# Install required packages
yum install mod_ssl openssl

# Generate private key
openssl genrsa -out server_name.com.key 2048

# Generate CSR
openssl req -new -key server_name.com.key -out server_name.com.csr

# Generate Self Signed Key – valid for 3 years
openssl x509 -req -days 1095 -in server_name.com.csr -signkey server_name.com.key -out server_name.com.crt

# If not exists, create following folder
mkdir -p /etc/httpd/ssl

# Copy certificate files to the directory
cp server_name.com.crt /etc/httpd/ssl/
cp server_name.com.key /etc/httpd/ssl/
cp server_name.com.csr /etc/httpd/ssl/

# Update following two lines in /etc/httpd/config.d/ssl.conf
SSLCertificateFile /etc/httpd/ssl/server_name.com.crt
SSLCertificateKeyFile /etc/httpd/ssl/server_name.com.key

# Restart web server
service httpd restart

 

Leave a Reply

Your email address will not be published. Required fields are marked *