Generating SSL certificate

To apply SSL connection in your server you have to use SSL certificate.
Here are the steps to create Self-Signed SSL certificate:

1. Install openssl.

yum install -y openssl

2. Create shell script

set -e


# Generate private key
openssl genrsa -out $prefix.key 2048

# Generate CSR
echo -e "[LOCALE]\n[COUNTRY]\n[CITY]\n[COMPANY]\nSSL\n$prefix\n[EMAIL]\n\n\n\n" \
	| (openssl req -new -key $prefix.key -out $prefix.csr)

# Generate Self Signed Key
openssl x509 -req -days 365 -in $prefix.csr -signkey $prefix.key -out $prefix.crt

# Copy the files to the correct locations
mv $prefix.crt /etc/ssl
mv $prefix.key /etc/ssl
mv $prefix.csr /etc/ssl

Replace [LOCALE], [COUNTRY], [CITY], [COMPANY], [EMAIL] with your values.

3. Run script example: