How to generate self signed ssl certificate in centos

Generating Self Signed SSL Certificate - Centos

Topic: How to generate self signed ssl certificate in centos

self signed ssl certificate

  About Self-Signed Certificates

            SSL Certificates, sometimes called digital certificates, are used to establish a secure encrypted connection between a browser (user's computer) and a server (website). The SSL connection protects sensitive data, such as credit card information, exchanged during each visit (session). Whether you need to secure one or many domains, one or multiple servers

  Self-signed certificates Drawbacks

                When using a self-signed certificate, there is no chain of trust. The certificate has signed itself. The web browser will then issue a warning, telling you that the web site certificate cannot be verified. Therefore, you should not use self-signed certificates for professional use, as your visitors will not trust your web site to be safe.

Below are the steps to generate Self signed ssl certificate in Apache using openssl

  Steps: Self Signed SSL Genertion

   Step 1 : installing the pre-requisites 

 In order to generate the self-signed certificate, we first have to be sure that apache ,openssl and modssl  are installed on your server

yum install apache openssl mod_ssl

   Step 2 : Create a new Directory

We need to create a new directory where we will store the server keys and certificates
mkdir /etc/httpd/ssl

   Step 3 : generating self signed certificates

While generating a new certificate we can specify how long  the certificate should remain valid .
Copy paste the below command(, which will generate a certificate with valid for 365 days, change it according to your requirement

openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/httpd/ssl/apache.key -out /etc/httpd/ssl/apache.crt

with this command ,we will be creating both the self signed ssl certificate and the server key and placing them both into the new directory.
This command will prompt terminal to display a lists of fields that need to be filled in.

The most important line is "Common Name". Enter your official domain name here or, if you don't have one yet, your server’s/site IP address.
Generating a 2048 bit RSA private key
writing new private key to '/etc/httpd/ssl/apache.key'
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.

Country Name (2 letter code) [XX]:IN
State or Province Name (full name) []:KARNATAKA
Locality Name (eg, city) [Default City]:SBC
Organization Name (eg, company) [Default Company Ltd]:STRIKER24X7
Organizational Unit Name (eg, section) []:DIALER
Common Name (eg, your name or your server's hostname) []:14.102.81.114
Email Address []:support@striker24x7.com

   Step 4 : Setting up the Certificate

Now we have all of the required components of the finished certificate.The next thing to do is to set up the virtual hosts to display the new certificate.
Open up the SSL config file:

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

Find the section that begins with <VirtualHost _default_:443> and make some quick changes.
Uncomment the DocumentRoot and ServerName line and replace example.com with your DNS approved domain name or server IP address (it should be the same as the common name on the certificate):

DocumentRoot "/var/www/html"
ServerName example.com:443

Find the following three lines, and make sure that they match the extensions below:

SSLEngine on
SSLCertificateFile /etc/httpd/ssl/apache.crt
SSLCertificateKeyFile /etc/httpd/ssl/apache.key
Your virtual host is now all set up! Save and Exit out of the file.

   Step 5 : Restart apache/httpd

/etc/init.d/httpd restart

In your browser, type https://youraddress to view the new certificate.

  Support

For support reach me on skype:striker24x7

Check out my youtube channel

https://youtube.com/c/striker24x7