{"id":822,"date":"2013-02-08T22:35:22","date_gmt":"2013-02-08T09:35:22","guid":{"rendered":"http:\/\/www.zoyinc.com\/?p=822"},"modified":"2013-09-29T19:48:21","modified_gmt":"2013-09-29T06:48:21","slug":"adding-an-ssl-certificate-to-apache","status":"publish","type":"post","link":"http:\/\/www.zoyinc.com\/?p=822","title":{"rendered":"Adding an SSL certificate to Apache"},"content":{"rendered":"<p>This article is about replacing an existing self-signed SSL certificate.<\/p>\n<p>In my case I have an Apache 2.2 server running on Fedora 14, pretty much default settings for a lot of stuff. My SSL certificate expired and I just needed to update it.<\/p>\n<p>In my case I have the &#8220;ssl.conf&#8221; in:<\/p>\n<p style=\"padding-left: 30px;\">\/etc\/httpd\/conf.d\/ssh.conf<\/p>\n<h2 style=\"text-align: left;\">Steps<\/h2>\n<table class=\"zsteps alignleft\" border=\"0\">\n<tbody>\n<tr>\n<td style=\"text-align: left;\">1.<\/td>\n<td>Login to a terminal\/ssl session on the box<\/td>\n<\/tr>\n<tr>\n<td>2.<\/td>\n<td>Stop Apache, in my case &#8220;\/etc\/init.d\/httpd&#8221;. This is not strictly necessary but probably a good idea<\/td>\n<\/tr>\n<tr>\n<td>3.<\/td>\n<td>Move to the directory where you will keep the SSL certificates and keys. Mine are in the same directory as my &#8220;ssl.conf&#8221; file:<\/p>\n<pre class=\"crayon:false;\">cd \/etc\/httpd\/conf.d<\/pre>\n<\/td>\n<\/tr>\n<tr>\n<td>4.<\/td>\n<td>If you don&#8217;t have a key or want to recreate one run something similar to:<\/p>\n<pre class=\"crayon:false;\">openssl genrsa -des3 -out zoyinc.com.key 1024<\/pre>\n<ul>\n<li>In this case the key name is obviously &#8220;zoyinc.com.key&#8221;.<\/li>\n<li>You will be asked for a &#8220;passphrase&#8221;, which is like a password to the key, so give it a key and note down what it is.<\/li>\n<li>You should find a key file called &#8220;zoyinc.com.key&#8221; created in the same directory.<\/li>\n<\/ul>\n<\/td>\n<\/tr>\n<tr>\n<td>5.<\/td>\n<td>Apache needs a key without a passphrase otherwise it won&#8217;t start, instead waiting for you to enter the passphrase, at least that&#8217;s my recollection. I imagine there is a way around it but I just change it to remove the passphrase &#8211; not something I would do in a production environment but for home I am happy.To create a key without a passphrase run:<\/p>\n<pre class=\"crayon:false;\">openssl rsa -in zoyinc.com.key -out zoyinc.com.nopassphrase.key\r\nrm zoyinc.com.key\r\nmv zoyinc.com.nopassphrase.key zoyinc.com.key<\/pre>\n<p>You will of course be prompted for the passphrase key.<\/td>\n<\/tr>\n<tr>\n<td>6.<\/td>\n<td>Now to generate a certificate. Run something similar to:<\/p>\n<pre class=\"crayon:false;\">openssl req -new -key zoyinc.com.key -x509 -days 1095 -out zoyinc.com.crt<\/pre>\n<ul>\n<li>Obviously the key needs to match the key you created earlier or a pre-existing.<\/li>\n<li>The &#8220;-days 1095&#8221; is how long the certificate should last before expiring. It is important to note the default is only one month. In this case I have set it for 1095 days which is 3 years.<\/li>\n<\/ul>\n<p>You will be prompted for various details for the certificate:<\/p>\n<ol>\n<li>Country Name &#8211; This is a two letter country code, in my case NZ<\/li>\n<li>State or Province Name &#8211; Optional<\/li>\n<li>Locality Name &#8211; Optional but usually city name<\/li>\n<li>Organization Name &#8211; Typically company name<\/li>\n<li>Organizational Unit Name &#8211; department within company, I put &#8220;Support&#8221;<\/li>\n<li>Common Name &#8211; This is important and is the name of your site, say &#8220;www.zoyinc.com&#8221;<\/li>\n<li>Email Address &#8211; Email address for people to contact you. This is public info so you may want to be careful what address you use.<\/li>\n<\/ol>\n<p>A thing that doesn&#8217;t seem to get much press is that the &#8220;Common Name&#8221; can include a wild card. So I have used &#8220;*.zoyinc.com&#8221; so it will be considered valid for &#8220;www.zoyinc.com&#8221; and &#8220;dev.zoyinc.com&#8221;.<\/td>\n<\/tr>\n<tr>\n<td>7.<\/td>\n<td>Restart Apache<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<p>Obviously you may need to update your &#8220;ssl.conf&#8221; file if you change the name of key or certificate<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This article is about replacing an existing self-signed SSL certificate. In my case I have an Apache 2.2 server running on Fedora 14, pretty much default settings for a lot of stuff. My SSL certificate expired and I just needed to update it. In my case I have the &#8220;ssl.conf&#8221; in: \/etc\/httpd\/conf.d\/ssh.conf Steps 1. Login [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":848,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[85],"tags":[305,88,87,86],"class_list":["post-822","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-apache","tag-apache","tag-certificate","tag-https","tag-ssl"],"_links":{"self":[{"href":"http:\/\/www.zoyinc.com\/index.php?rest_route=\/wp\/v2\/posts\/822","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.zoyinc.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.zoyinc.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.zoyinc.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.zoyinc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=822"}],"version-history":[{"count":26,"href":"http:\/\/www.zoyinc.com\/index.php?rest_route=\/wp\/v2\/posts\/822\/revisions"}],"predecessor-version":[{"id":1637,"href":"http:\/\/www.zoyinc.com\/index.php?rest_route=\/wp\/v2\/posts\/822\/revisions\/1637"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/www.zoyinc.com\/index.php?rest_route=\/wp\/v2\/media\/848"}],"wp:attachment":[{"href":"http:\/\/www.zoyinc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=822"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.zoyinc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=822"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.zoyinc.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=822"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}