{"id":1623,"date":"2018-02-12T16:28:32","date_gmt":"2018-02-12T23:28:32","guid":{"rendered":"http:\/\/jim-zimmerman.com\/?p=1623"},"modified":"2018-02-12T16:28:32","modified_gmt":"2018-02-12T23:28:32","slug":"centos-7-certificate-for-apache-notes","status":"publish","type":"post","link":"https:\/\/jim-zimmerman.com\/?p=1623","title":{"rendered":"CentOS 7 &#8211; Certificate For Apache Notes."},"content":{"rendered":"<p>Generate a key and CSR:<\/p>\n<blockquote><p># openssl req -new -key ca.key -out ca.csr<br \/>\nYou are about to be asked to enter information that will be incorporated<br \/>\ninto your certificate request.<br \/>\nWhat you are about to enter is what is called a Distinguished Name or a DN.<br \/>\nThere are quite a few fields but you can leave some blank<br \/>\nFor some fields there will be a default value,<br \/>\nIf you enter &#8216;.&#8217;, the field will be left blank.<br \/>\n&#8212;&#8211;<br \/>\nCountry Name (2 letter code) [XX]:US<br \/>\nState or Province Name (full name) []:California<br \/>\nLocality Name (eg, city) [Default City]:Valencia<br \/>\nOrganization Name (eg, company) [Default Company Ltd]:GreatTechHelp<br \/>\nOrganizational Unit Name (eg, section) []:Information Systems<br \/>\nCommon Name (eg, your name or your server&#8217;s hostname) []:myhostname<br \/>\nEmail Address []:some@email.address<\/p>\n<p>Please enter the following &#8216;extra&#8217; attributes<br \/>\nto be sent with your certificate request<br \/>\nA challenge password []:<br \/>\nAn optional company name []:<\/p><\/blockquote>\n<p>Files created:<\/p>\n<blockquote><p># ls<br \/>\nca.csr  ca.key <\/p><\/blockquote>\n<p>Sign the key:<\/p>\n<blockquote><p># openssl x509 -req -days 365 -in ca.csr -signkey ca.key -out ca.crt<br \/>\nSignature ok<br \/>\nsubject=\/C=US\/ST=California\/L=Valencia\/O=GreatTechHelp\/OU=Information Systems\/CN=myhostname\/emailAddress=some@email.address<br \/>\nGetting Private key<\/p><\/blockquote>\n<p>Copy the certificate, key and csr files and set the permisions:<\/p>\n<blockquote><p># cp ca.crt \/etc\/pki\/tls\/certs\/<br \/>\n# cp ca.key \/etc\/pki\/tls\/private\/ca.key<br \/>\n# cp ca.csr \/etc\/pki\/tls\/private\/ca.csr<br \/>\n# chmod 600 \/etc\/pki\/tls\/certs\/<br \/>\n# chmod 600 \/etc\/pki\/tls\/private\/ca.key<br \/>\n# chmod 600 \/etc\/pki\/tls\/private\/ca.csr<\/p><\/blockquote>\n<p>Edit the apache configuration for the VirtualHost or site (Virtual host in this example.):<\/p>\n<blockquote><p># cd \/etc\/httpd\/conf.d\/<br \/>\n# ls<br \/>\nautoindex.conf  myhostname.conf  php.conf  README  ssl.conf  userdir.conf  welcome.conf<br \/>\n# vi myhostname.conf<br \/>\n<VirtualHost *:80><br \/>\n        ServerName server.domain.tld<br \/>\n        ServerAlias someothername<br \/>\n        DocumentRoot \/var\/www\/html<br \/>\n<\/VirtualHost><\/p>\n<p>NameVirtualHost *:443<\/p>\n<p><VirtualHost *:80><br \/>\n        ServerName myhostname.greattechhelp.com<br \/>\n        ServerAlias myhostname<br \/>\n        DocumentRoot \/var\/www\/html\/myhostname<br \/>\n\tRewriteEngine On<br \/>\n\tRewriteCond %{HTTPS} !on<br \/>\n\tRewriteRule (.*) https:\/\/%{HTTP_HOST}%{REQUEST_URI}<br \/>\n<\/VirtualHost><\/p>\n<p><VirtualHost *:443><br \/>\n\tSSLEngine on<br \/>\n\tSSLCertificateFile \/etc\/pki\/tls\/certs\/ca.crt<br \/>\n\tSSLCertificateKeyFile \/etc\/pki\/tls\/private\/ca.key<br \/>\n        <Directory \/var\/www\/html\/myhostname><br \/>\n\t\tAllowOverride All<br \/>\n\t<\/Directory><br \/>\n        DocumentRoot \/var\/www\/html\/myhostname<br \/>\n        ServerName myhostname.greattechhelp.com<br \/>\n        ServerAlias myhostname<br \/>\n<\/VirtualHost><\/p><\/blockquote>\n<p>Restart apache:<\/p>\n<blockquote><p># systemctl restart httpd<\/p><\/blockquote>\n<p>To renew the cert:<\/p>\n<blockquote><p># cp -p \/etc\/pki\/tls\/certs\/ca.crt \/etc\/pki\/tls\/certs\/ca.crt.bak<br \/>\n# cp -p \/etc\/pki\/tls\/private\/ca.key \/etc\/pki\/tls\/private\/ca.key.bak<br \/>\n# openssl req -new -days 365 -x509 -nodes -newkey rsa:2048 -out \/etc\/pki\/tls\/certs\/ca.crt -keyout \/etc\/pki\/tls\/private\/ca.key<br \/>\n# systemctl restart httpd<\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>Generate a key and CSR: # openssl req -new -key ca.key -out ca.csr 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 [&#038;hellip<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[120,456,331,462,461],"class_list":["post-1623","post","type-post","status-publish","format-standard","hentry","category-documentation","tag-apache","tag-certificate","tag-redirect","tag-renew","tag-self-signed"],"share_on_mastodon":{"url":"","error":""},"_links":{"self":[{"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=\/wp\/v2\/posts\/1623","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1623"}],"version-history":[{"count":1,"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=\/wp\/v2\/posts\/1623\/revisions"}],"predecessor-version":[{"id":1624,"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=\/wp\/v2\/posts\/1623\/revisions\/1624"}],"wp:attachment":[{"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1623"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1623"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1623"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}