How To Create a SSL Certificate on Apache for CentOS 6


SUBMITTED BY: Guest

DATE: Jan. 10, 2015, 5:11 p.m.

FORMAT: Text only

SIZE: 3.6 kB

HITS: 878

  1. About Self-Signed Certificates
  2. A SSL certificate is a way to encrypt a site's information and create a more secure connection. Additionally, the certificate can show the virtual private server's identification information to site visitors. Certificate Authorities can issue SSL certificates that verify the virtual server's details while a self-signed certificate has no 3rd party corroboration.
  3. - Step 1: Install Mod SSL
  4. In order to set up the self signed certificate, we first have to be sure that Apache and Mod SSL are installed on our VPS. You can install both with one command:
  5. sudo yum install mod_ssl
  6. - Step 2: Create a New Directory
  7. Next, we need to create a new directory where we will store the server key and certificate
  8. sudo mkdir -p /etc/httpd/ssl
  9. - Step 3: Create a Self Signed Certificate
  10. When we request a new certificate, we can specify how long the certificate should remain valid by changing the 365 to the number of days we prefer. As it stands this certificate will expire after one year.
  11. openssl req -x509 -nodes -day 365 -newkey rsa:2048 -keyout /etc/httpd/ssl/apache.key -out /etc/httpd/ssl/apache.crt
  12. With this command, we will be both creating the self-signed SSL certificate and the server key that protects it, and placing both of them into the new directory.
  13. This command will prompt terminal to display a lists of fields that need to be filled in.
  14. The most important line is "Common Name". Enter your official domain name here or, if you don't have one yet, your site's IP address.
  15. You are about to be asked to enter information that will be incorporated
  16. into your certificate request.
  17. What you are about to enter is what is called a Distinguished Name or a DN.
  18. There are quite a few fields but you can leave some blank
  19. For some fields there will be a default value,
  20. If you enter '.', the field will be left blank.
  21. -----
  22. Country Name (2 letter code) [AU]:US
  23. State or Province Name (full name) [Some-State]:New York
  24. Locality Name (eg, city) []:NYC
  25. Organization Name (eg, company) [Internet Widgits Pty Ltd]:Nowquestion
  26. Organizational Unit Name (eg, section) []:nowquetion.net
  27. Common Name (e.g. server FQDN or YOUR name) []:domain.com
  28. Email Address []:contact@domain.com
  29. - Step 4: Set Up the Certificate
  30. 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.
  31. Open up the SSL config file:
  32. nano /etc/httpd/conf.d/ssl.conf
  33. Find the section that begins with <VirtualHost _default_:443> and make some quick changes.
  34. 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):
  35. ServerName domain:443
  36. Find the following three lines, and make sure that they match the extensions below:
  37. SSLEngine on
  38. SSLCertificateFile /etc/httpd/ssl/apache.crt
  39. SSLCertificateKeyFile /etc/httpd/ssl/apache.key
  40. Your virtual host is now all set up! Save and Exit out of the file.
  41. - Step 4: Restart Apache
  42. You are done. Restarting the Apache server will reload it with all of your changes in place.
  43. service httpd restart
  44. In your browser, type https://youraddress to view the new certificate.
  45. http://nowquestion.net/questions/how-to-create-a-ssl-certificate-on-apache-for-centos-6

comments powered by Disqus