{"id":32,"date":"2015-08-03T16:12:33","date_gmt":"2015-08-03T15:12:33","guid":{"rendered":"http:\/\/www.haxed.me.uk\/?p=32"},"modified":"2015-08-03T16:24:56","modified_gmt":"2015-08-03T15:24:56","slug":"installing-ssl-certificates-with-apache2","status":"publish","type":"post","link":"https:\/\/haxed.me.uk\/index.php\/2015\/08\/03\/installing-ssl-certificates-with-apache2\/","title":{"rendered":"Installing SSL Certificates with Apache2"},"content":{"rendered":"<p>At work we have recently had a lot of customers asking us about how to configure their SSL certificate files for their webserver. This may seem intimidating to many persons, especially those without any technical experience, however it really need not be so frustrating. There are only just a few things that need to be done to make sure that your website can use HTTPS SSL (or the secure hypertext transfer protocol (https) using the secure sockets layer (SSL). This tutorial should be good for most debian, centos, and redhat operating systems, or nearly any linux distribution, but you may need to install nano;<\/p>\n<blockquote><p># for debian or ubuntu<\/p>\n<p>apt-get install nano<\/p>\n<p>&nbsp;<\/p>\n<p># for centos or Redhat<\/p>\n<p>yum install nano<\/p><\/blockquote>\n<p><strong>You will have likely been sent two files by your registrar or SSL provider which are<br \/>\nthe CRT and KEY file. Each file you have been sent looks a bit like the following, you cannot do this tutorial without these two files:<br \/>\n<\/strong><\/p>\n<p><strong>yourdomainname.com.crt<\/strong><\/p>\n<blockquote><p>&#8212;&#8211;BEGIN CERTIFICATE REQUEST&#8212;&#8211;<br \/>\nMIICJDCCAY0CAQAwgagxGzAZBgNVBAoTElRoZSBTYW1wbGUgQ29tcGFueTEUMBIG<br \/>\nA1UECxMLTWFpbCBTZXJ2ZXIxJDAiBgkqhkiG9w0BCQEWFXBvc3RtYXN0ZXJAc2Ft<br \/>\ncGxlLmNvbTETMBEGA1UEBxMKTWV0cm9wb2xpczERMA8GA1UECBMITmV3IFlvcmsx<br \/>\nCzAJBgNVBAYTAlVTMRgwFgYDVQQDEw9tYWlsLnNhbXBsZS5jb20wgZ8wDQYJKoZI<br \/>\nhvcNAQEBBQADgY0AMIGJAoGBAPJhc++WxcBaoDbJpzFbDg42NcOz\/ELVFMU4FlPa<br \/>\nyUzUO+xXkdFRMPKo54d4Pf1w575Jhlu9lE+kJ8QN2st6JFySbc9QjPwVwl9D2+I3<br \/>\nSSf2kVTu+2Ur5izCPbVAfU0rPZxxK8ELoOkA1uwwjFz6EFuVvnHwlguonWKDtmYW<br \/>\nu7KTAgMBAAGgOzA5BgkqhkiG9w0BCQ4xLDAqMAkGA1UdEwQCMAAwHQYDVR0OBBYE<br \/>\nFLWaQsUVIQzWr58HtDinH1JfeCheMA0GCSqGSIb3DQEBBAUAA4GBAAbe0jrGEQ3i<br \/>\ntyVfy5Lg4\/f69rKvDGs+uhZJ9ZRx7Dl92Qq2osE7XrLB1bANmcoEv\/ORLZOjWZEY<br \/>\nNjMvuz60O7R8GKBrvb\/YhAwWhIIt2LJqPkpAEWS0kY0AkoQcfZ7h6oC35+eJ7okg<br \/>\nUu3WuE57RgcNt7\/ftr0sG1jUyRwMLvhv<br \/>\n&#8212;&#8211;END CERTIFICATE REQUEST&#8212;&#8211;<\/p><\/blockquote>\n<p><strong>yourdomainname.com.key<\/strong><\/p>\n<blockquote><p>&#8212;&#8211;BEGIN CERTIFICATE REQUEST&#8212;&#8211;<br \/>\nLKSDIJUCJCdsjdicx933FKJ\u00a3DKCJDIDKFJVKSIdjjhan3FGdf1wbGUgQ29tcGFueTEUMBIG<br \/>\nA1UECxMLTWFpbCBTZXJ2ZXIxJDAiBgkqhkiG9w0BCQEWFXBvc3RtYXN0ZXJAc2Ft<br \/>\ncGxlLmNvbTETMBEGA1UEBxMKTWV0cm9wb2xpczERMA8GA1UECBMITmV3IFlvcmsx<br \/>\nCzAJBgNVBAYTAlVTMRgwFgYDVQQDEw9tYWlsLnNhbXBsZS5jb20wgZ8wDQYJKoZI<br \/>\nhvcNAQEBBQADgY0AMIGJAoGBAPJhc++WxcBaoDbJpzFbDg42NcOz\/ELVFMU4FlPa<br \/>\nyUzUO+xXkdFRMPKo54d4Pf1w575Jhlu9lE+kJ8QN2st6JFySbc9QjPwVwl9D2+I3<br \/>\nSSf2kVTu+2Ur5izCPbVAfU0rPZxxK8ELoOkA1uwwjFz6EFuVvnHwlguonWKDtmYW<br \/>\nu7KTAgMBAAGgOzA5BgkqhkiG9w0BCQ4xLDAqMAkGA1UdEwQCMAAwHQYDVR0OBBYE<br \/>\nFLWaQsUVIQzWr58HtDinH1JfeCheMA0GCSqGSIb3DQEBBAUAA4GBAAbe0jrGEQ3i<br \/>\ntyVfy5Lg4\/f69rKvDGs+uhZJ9ZRx7Dl92Qq2osE7XrLB1bANmcoEv\/ORLZOjWZEY<br \/>\nNjMvuz60O7R8GKBrvb\/YhAwWhIIt2LJqPkpAEWS0kY0AkoQcfZ7h6oC35+eJ7okg<br \/>\nUu3WuE57RgcNt7\/ftr0sG1jUyRwMLvhv<br \/>\n&#8212;&#8211;END CERTIFICATE REQUEST&#8212;&#8211;<\/p><\/blockquote>\n<p>(DO NOT USE THE ABOVE CERTIFICATES (THEY WILL NOT WORK) USE THE ONES YOU ARE PROVIDED)<\/p>\n<p><strong>Step 1: Copy the CRT text into the clipboard<\/strong> (including the &#8212;&#8211;BEGIN CERTIFICATE REQUEST&#8212;&#8211; and the &#8212;&#8211;END CERTIFICATE REQUEST&#8212;&#8211;) but <strong>nothing above<\/strong> the begin certificate line and <strong>nothing below<\/strong> the end certificate line. This is\u00a0<strong>very important.\u00a0<\/strong><\/p>\n<p><strong>Step 2: Open a new file<\/strong> for the CRT<\/p>\n<blockquote><p>mkdir -p \/etc\/httpd\/conf\/ssl.crt\/<br \/>\nnano \/etc\/httpd\/conf\/ssl.crt\/yourdomain.com.crt<\/p><\/blockquote>\n<p>Step 3: <strong>Paste in the CRT<\/strong> certificate text you were given.<br \/>\nStep 4: <strong>Press CTRL+O<\/strong> to write out the file.<\/p>\n<p>Step 5:<strong> Copy the<\/strong> <strong>KEY <\/strong>text into the clipboard in the same way you did for the CRT.<\/p>\n<p>Step 6: <strong>Open a new file<\/strong> for the key file<\/p>\n<blockquote><p>mkdir \/p \/etc\/httpd\/conf\/ssl.key\/<\/p>\n<p>nano \/etc\/httpd\/conf\/ssl.key\/yourdomain.com.key<\/p><\/blockquote>\n<p>Step 7: <strong>Paste the KEY<\/strong> certificate text.<br \/>\nStep 8: <strong>Press CTRL+O<\/strong> to write out the file.<\/p>\n<p><strong>It is safe for you to replace yourdomain.com with your own domain name, but make sure that you specify it the same in the apache2 configuration later on.<\/strong> This is the file we will refer to in the webserver configuration to let it use https and ssl and if you refer to the wrong file or a non existent file it won&#8217;t work!<\/p>\n<p>Step 9: Edit your apache 2 webserver configuration.<\/p>\n<p>(Normally this is in \/etc\/apache2\/httpd.conf or \/etc\/httpd\/httpd.conf , but it could be in a different place like \/etc\/httpd\/sites-enabled or \/etc\/apache2\/sites-enabled or \/etc\/apache2\/conf.d and my have a different name to httpd.conf.)<\/p>\n<pre id=\"pre-0\">&lt;VirtualHost 1.1.1.1:443&gt;\r\nServerName www.yourdomain.com\r\nDocumentRoot \/var\/www\/html\/mydomain.com\r\n\r\nSSLEngine ON\r\nSSLCertificateFile \/etc\/httpd\/conf\/ssl.crt\/domain.com.crt\r\nSSLCertificateKeyFile \/etc\/httpd\/conf\/ssl.key\/domain.com.key\r\n\r\nErrorLog logs\/ssl.domain.com.error_log\r\nCustomLog logs\/ssl.domain.com.access_log combined\r\n&lt;\/VirtualHost&gt;\r\n<\/pre>\n<p>It&#8217;s important to get all of this correct. So lets go thru what each one of these lines does.<\/p>\n<p><strong>VirtualHost<\/strong> tells apache2 where to listen. If you don&#8217;t know what to put here you can use:<br \/>\n&lt;VirtualHost *:443&gt; which will work for most configurations, but it will listen on every single IP address attached to that machine. The 443 signifies that it is the HTTPS. HTTP traffic for instance runs on port 80.<\/p>\n<p><strong>ServerName<\/strong> is the website name your using so if your website is https:\/\/www.google.com , for instance then you want to put ServerName www.google.com.<\/p>\n<p><strong>DocumentRoot<\/strong> is the location of your website on the disk, the physical location of all the files, be they html, php, images etc, DocumentRoot is the way the webserver knows where to look when serving that website hostname. For me I use \/var\/www\/html but if you don&#8217;t know it&#8217;s best to ask your provider or technical contact what your DocumentRoot here should be.<\/p>\n<p><strong>SSLEngine<\/strong> ON does exactly what it says on the tin. It enables apache2&#8217;s SSL HTTPS functionality.<\/p>\n<p><strong>SSLCertificateFile<\/strong> tells where apache2 is instructed to look for the CRT file you were given by your webhost. Make sure you specify it in the same location you placed it.<\/p>\n<p><strong>SSLCertificateKeyFile<\/strong> tells where apache2 is instructed to look for the KEY file you were given by your webhost. Make sure you specify it in the same location you placed it.<\/p>\n<p><strong>ErrorLog<\/strong> and <strong>CustomLog<\/strong> give the location on the hardisk to place the logs for the access to this website.<\/p>\n<p>Step 10: <strong>Enable the SSL module<\/strong> for apache2 by running<\/p>\n<blockquote><p>a2enmod ssl<\/p><\/blockquote>\n<p>Step 11: <strong>Restart Apache2<\/strong> so that the configurations changes are loaded<\/p>\n<blockquote><p>\/etc\/init.d\/apache2 restart<\/p><\/blockquote>\n<p>Step 11B: <strong>If Step 11 fails<\/strong> to complete then use<\/p>\n<blockquote><p>service apache2 restart<\/p><\/blockquote>\n<p>That is it , you should be done configuring your apache2 SSL configuration. It&#8217;s not that hard is it? Admittedly I&#8217;ve done this before a few times myself, and I am sure that after you have done the same it will be second nature.<\/p>\n<p>Best wishes,<br \/>\nAdam<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>At work we have recently had a lot of customers asking us about how to configure their SSL certificate files for their webserver. This may seem intimidating to many persons, especially those without any technical experience, however it really need &hellip; <a href=\"https:\/\/haxed.me.uk\/index.php\/2015\/08\/03\/installing-ssl-certificates-with-apache2\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-32","post","type-post","status-publish","format-standard","hentry","category-uncategorised"],"_links":{"self":[{"href":"https:\/\/haxed.me.uk\/index.php\/wp-json\/wp\/v2\/posts\/32","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/haxed.me.uk\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/haxed.me.uk\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/haxed.me.uk\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/haxed.me.uk\/index.php\/wp-json\/wp\/v2\/comments?post=32"}],"version-history":[{"count":0,"href":"https:\/\/haxed.me.uk\/index.php\/wp-json\/wp\/v2\/posts\/32\/revisions"}],"wp:attachment":[{"href":"https:\/\/haxed.me.uk\/index.php\/wp-json\/wp\/v2\/media?parent=32"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/haxed.me.uk\/index.php\/wp-json\/wp\/v2\/categories?post=32"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/haxed.me.uk\/index.php\/wp-json\/wp\/v2\/tags?post=32"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}