Renewing certificates

This commit is contained in:
Bob Mottram 2015-03-07 21:25:40 +00:00
parent 6d02c62c95
commit f4c305d3a5
2 changed files with 252 additions and 11 deletions

View File

@ -17,6 +17,7 @@
| [[Why isn't dynamic DNS working?]] |
| [[How do I get a domain name?]] |
| [[How do I get a "real" SSL certificate?]] |
| [[How do I renew a StartSSL certificate?]] |
| [[Why use self-signed certificates?]] |
| [[Why not use the services of $company instead? They took the Seppuku pledge]] |
| [[Why does my email keep getting rejected as spam by Gmail/etc?]] |
@ -240,6 +241,97 @@ service nginx restart
Now visit your web site at https://mydomainname.com and you should notice that there is no certificate warning displayed. You will now be able to install systems which don't allow the use of self-signed certificates, such as [[https://redmatrix.me/&JS=1][Red Matrix]].
* How do I renew a StartSSL certificate?
The StartSSL certificates last for a year. You can check the expiry date of your current certificate/s by going to your site and if you're using Firefox then click on the *lock icon*, select "*more information*" then "*view certificate*".
Make sure that you have the StartSSL certificate which was created when you initially made an account. You did save it somewhere safe, didn't you? If it's not installed into your browser then in Firefox go to *Menu/Preferences/Advanced/View Certificates*. Make sure the "*Your Cerificates*" tab is selected and click "*import*", then import the StartSSL certificate.
Now go to [[startssl.com]] and click on the keys icon on the right hand side to log in. Select the *Control panel* then *Validations Wizard* and choose *Email address validation*. Enter your email address, then wait for the validation email to show up in your inbox. It will contain a code when you can then enter.
Once your email is validated then go to *Validations Wizard* and choose *Domain name validation*. Enter your domain name and select *postmaster@yourdomainname*. After a while you should receive a validation email and you can then enter the code.
Log into the Freedombone and become the root user. Now we can generate a new certificate request as follows.
#+BEGIN_SRC bash
export HOSTNAME=mydomainname.com
openssl genrsa -out /etc/ssl/private/$HOSTNAME.new.key 2048
chown root:ssl-cert /etc/ssl/private/$HOSTNAME.new.key
chmod 440 /etc/ssl/private/$HOSTNAME.new.key
mkdir /etc/ssl/requests
#+END_SRC
Now make a certificate request as follows. You should copy and paste the whole of this, not just line by line.
#+BEGIN_SRC bash
openssl req -new -sha256 -key /etc/ssl/private/$HOSTNAME.new.key -out /etc/ssl/requests/$HOSTNAME.csr
#+END_SRC
For the email address it's a good idea to use postmaster@mydomainname.
Use a random 20 character password, and keep a note of it. We'll remove this later.
View the request with:
#+BEGIN_SRC bash
cat /etc/ssl/requests/$HOSTNAME.csr
#+END_SRC
On the StartSSL site select *Certificates Wizard* then *Web server SSL/TLS Certificate*. You can then click on "skip" and then copy and paste the encrypted request into the text entry box. You may now need to wait a few hours for a confirmation email indicating that the new certificate was created.
Select *Tool Box* and then *Retrieve Certificate* from the list. Make sure to choose the one with the correct expiration date. Copy the text.
#+BEGIN_SRC bash
mv /etc/ssl/private/$HOSTNAME.new.key /etc/ssl/private/$HOSTNAME.key
editor /etc/ssl/certs/$HOSTNAME.crt
#+END_SRC
Delete any existing contents then paste the public key from the StartSSL site. Save and exit. Then run the following commands:
#+BEGIN_SRC bash
mkdir /etc/ssl/roots
mkdir /etc/ssl/chains
wget "http://www.startssl.com/certs/ca.pem" --output-document="/etc/ssl/roots/startssl-root.ca"
wget "http://www.startssl.com/certs/sub.class1.server.ca.pem" --output-document="/etc/ssl/chains/startssl-sub.class1.server.ca.pem"
wget "http://www.startssl.com/certs/sub.class2.server.ca.pem" --output-document="/etc/ssl/chains/startssl-sub.class2.server.ca.pem"
wget "http://www.startssl.com/certs/sub.class3.server.ca.pem" --output-document="/etc/ssl/chains/startssl-sub.class3.server.ca.pem"
ln -s "/etc/ssl/roots/startssl-root.ca" "/etc/ssl/roots/$HOSTNAME-root.ca"
ln -s "/etc/ssl/chains/startssl-sub.class1.server.ca.pem" "/etc/ssl/chains/$HOSTNAME.ca"
cp "/etc/ssl/certs/$HOSTNAME.crt" "/etc/ssl/certs/$HOSTNAME.crt+chain+root"
test -e "/etc/ssl/chains/$HOSTNAME.ca" && cat "/etc/ssl/chains/$HOSTNAME.ca" >> "/etc/ssl/certs/$HOSTNAME.crt+chain+root"
test -e "/etc/ssl/roots/$HOSTNAME-root.ca" && cat "/etc/ssl/roots/$HOSTNAME-root.ca" >> "/etc/ssl/certs/$HOSTNAME.crt+chain+root"
#+END_SRC
Remove the certificate password, so if the server is rebooted then it won't wait indefinitely for a non-existant keyboard user to type in a password.
#+BEGIN_SRC bash
openssl rsa -in /etc/ssl/private/$HOSTNAME.key -out /etc/ssl/private/$HOSTNAME.new.key
cp /etc/ssl/private/$HOSTNAME.new.key /etc/ssl/private/$HOSTNAME.key
shred -zu /etc/ssl/private/$HOSTNAME.new.key
#+END_SRC
Create a bundled certificate which joins the certificate and chain file together.
#+BEGIN_SRC bash
cat /etc/ssl/certs/$HOSTNAME.crt /etc/ssl/chains/startssl-sub.class1.server.ca.pem > /etc/ssl/certs/$HOSTNAME.bundle.crt
#+END_SRC
And also add it to the overall bundle of certificates for the Freedombone. This will allow you to easily install the certificates onto other systems.
#+BEGIN_SRC bash
cp /etc/ssl/certs/$HOSTNAME.bundle.crt /etc/ssl/mycerts
cat /etc/ssl/mycerts/*.crt > /etc/ssl/freedombone-bundle.crt
tar -czvf /etc/ssl/freedombone-certs.tar.gz /etc/ssl/mycerts/*.crt
#+END_SRC
To avoid any possibility of the certificates being accidentally overwritten by self-signed ones at a later date you can create backups.
#+BEGIN_SRC bash
cp /etc/ssl/certs/$HOSTNAME* /etc/ssl/backups/certs/
cp /etc/ssl/private/$HOSTNAME* /etc/ssl/backups/private/
chmod -R 400 /etc/ssl/backups/certs/*
chmod -R 400 /etc/ssl/backups/private/*
#+END_SRC
* Why use self-signed certificates?
Almost everywhere on the web you will read that self-signed certificates are worthless. They bring up scary looking browser warnings and gurus will advise you not to use them. Self-signed certificates are quite useful though. What the scary warnings mean - and it would be good if they explained this more clearly - is that you have an encrypted connection established but there is /no certainty about who that connection is with/. The usual solution to this is to get a "real" SSL certificate from one of the certificate authorities, but it's far from clear that such authorities can be trusted. There have been various scandals involving such organisations, and it does not seem plausible to assume that they are somehow immune to the sort of treatment which [[http://en.wikipedia.org/wiki/Lavabit][Lavabit]] received. So although most internet users have been trained to look for the lock icon as an indication that the connection is secured that belief may not always be well founded.

View File

@ -4,7 +4,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title></title>
<!-- 2015-03-07 Sat 13:17 -->
<!-- 2015-03-07 Sat 21:24 -->
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<meta name="generator" content="Org-mode" />
<meta name="author" content="Bob Mottram" />
@ -194,15 +194,19 @@ for the JavaScript code in this tag.
</tr>
<tr>
<td class="left"><a href="#unnumbered-7">Why use self-signed certificates?</a></td>
<td class="left"><a href="#unnumbered-7">How do I renew a StartSSL certificate?</a></td>
</tr>
<tr>
<td class="left"><a href="#unnumbered-8">Why not use the services of $company instead? They took the Seppuku pledge</a></td>
<td class="left"><a href="#unnumbered-8">Why use self-signed certificates?</a></td>
</tr>
<tr>
<td class="left"><a href="#unnumbered-9">Why does my email keep getting rejected as spam by Gmail/etc?</a></td>
<td class="left"><a href="#unnumbered-9">Why not use the services of $company instead? They took the Seppuku pledge</a></td>
</tr>
<tr>
<td class="left"><a href="#unnumbered-10">Why does my email keep getting rejected as spam by Gmail/etc?</a></td>
</tr>
</tbody>
</table>
@ -555,9 +559,154 @@ Now visit your web site at <a href="https://mydomainname.com/">https://mydomainn
</div>
<div id="outline-container-unnumbered-7" class="outline-2">
<h2 id="unnumbered-7">Why use self-signed certificates?</h2>
<h2 id="unnumbered-7">How do I renew a StartSSL certificate?</h2>
<div class="outline-text-2" id="text-unnumbered-7">
<p>
The StartSSL certificates last for a year. You can check the expiry date of your current certificate/s by going to your site and if you're using Firefox then click on the <b>lock icon</b>, select "<b>more information</b>" then "<b>view certificate</b>".
</p>
<p>
Make sure that you have the StartSSL certificate which was created when you initially made an account. You did save it somewhere safe, didn't you? If it's not installed into your browser then in Firefox go to <b>Menu/Preferences/Advanced/View Certificates</b>. Make sure the "<b>Your Cerificates</b>" tab is selected and click "<b>import</b>", then import the StartSSL certificate.
</p>
<p>
Now go to <i>startssl.com</i> and click on the keys icon on the right hand side to log in. Select the <b>Control panel</b> then <b>Validations Wizard</b> and choose <b>Email address validation</b>. Enter your email address, then wait for the validation email to show up in your inbox. It will contain a code when you can then enter.
</p>
<p>
Once your email is validated then go to <b>Validations Wizard</b> and choose <b>Domain name validation</b>. Enter your domain name and select <b>postmaster@yourdomainname</b>. After a while you should receive a validation email and you can then enter the code.
</p>
<p>
Log into the Freedombone and become the root user. Now we can generate a new certificate request as follows.
</p>
<div class="org-src-container">
<pre class="src src-bash"><span class="org-builtin">export</span> <span class="org-variable-name">HOSTNAME</span>=mydomainname.com
openssl genrsa -out /etc/ssl/private/$<span class="org-variable-name">HOSTNAME</span>.new.key 2048
chown root:ssl-cert /etc/ssl/private/$<span class="org-variable-name">HOSTNAME</span>.new.key
chmod 440 /etc/ssl/private/$<span class="org-variable-name">HOSTNAME</span>.new.key
mkdir /etc/ssl/requests
</pre>
</div>
<p>
Now make a certificate request as follows. You should copy and paste the whole of this, not just line by line.
</p>
<div class="org-src-container">
<pre class="src src-bash">openssl req -new -sha256 -key /etc/ssl/private/$<span class="org-variable-name">HOSTNAME</span>.new.key -out /etc/ssl/requests/$<span class="org-variable-name">HOSTNAME</span>.csr
</pre>
</div>
<p>
For the email address it's a good idea to use postmaster@mydomainname.
</p>
<p>
Use a random 20 character password, and keep a note of it. We'll remove this later.
</p>
<p>
View the request with:
</p>
<div class="org-src-container">
<pre class="src src-bash">cat /etc/ssl/requests/$<span class="org-variable-name">HOSTNAME</span>.csr
</pre>
</div>
<p>
On the StartSSL site select <b>Certificates Wizard</b> then <b>Web server SSL/TLS Certificate</b>. You can then click on "skip" and then copy and paste the encrypted request into the text entry box. You may now need to wait a few hours for a confirmation email indicating that the new certificate was created.
</p>
<p>
Select <b>Tool Box</b> and then <b>Retrieve Certificate</b> from the list. Make sure to choose the one with the correct expiration date. Copy the text.
</p>
<div class="org-src-container">
<pre class="src src-bash">mv /etc/ssl/private/$<span class="org-variable-name">HOSTNAME</span>.new.key /etc/ssl/private/$<span class="org-variable-name">HOSTNAME</span>.key
editor /etc/ssl/certs/$<span class="org-variable-name">HOSTNAME</span>.crt
</pre>
</div>
<p>
Delete any existing contents then paste the public key from the StartSSL site. Save and exit. Then run the following commands:
</p>
<div class="org-src-container">
<pre class="src src-bash">mkdir /etc/ssl/roots
mkdir /etc/ssl/chains
wget <span class="org-string">"http://www.startssl.com/certs/ca.pem"</span> --output-document=<span class="org-string">"/etc/ssl/roots/startssl-root.ca"</span>
wget <span class="org-string">"http://www.startssl.com/certs/sub.class1.server.ca.pem"</span> --output-document=<span class="org-string">"/etc/ssl/chains/startssl-sub.class1.server.ca.pem"</span>
wget <span class="org-string">"http://www.startssl.com/certs/sub.class2.server.ca.pem"</span> --output-document=<span class="org-string">"/etc/ssl/chains/startssl-sub.class2.server.ca.pem"</span>
wget <span class="org-string">"http://www.startssl.com/certs/sub.class3.server.ca.pem"</span> --output-document=<span class="org-string">"/etc/ssl/chains/startssl-sub.class3.server.ca.pem"</span>
ln -s <span class="org-string">"/etc/ssl/roots/startssl-root.ca"</span> <span class="org-string">"/etc/ssl/roots/$HOSTNAME-root.ca"</span>
ln -s <span class="org-string">"/etc/ssl/chains/startssl-sub.class1.server.ca.pem"</span> <span class="org-string">"/etc/ssl/chains/$HOSTNAME.ca"</span>
cp <span class="org-string">"/etc/ssl/certs/$HOSTNAME.crt"</span> <span class="org-string">"/etc/ssl/certs/$HOSTNAME.crt+chain+root"</span>
<span class="org-builtin">test</span> -e <span class="org-string">"/etc/ssl/chains/$HOSTNAME.ca"</span> &amp;&amp; cat <span class="org-string">"/etc/ssl/chains/$HOSTNAME.ca"</span> &gt;&gt; <span class="org-string">"/etc/ssl/certs/$HOSTNAME.crt+chain+root"</span>
<span class="org-builtin">test</span> -e <span class="org-string">"/etc/ssl/roots/$HOSTNAME-root.ca"</span> &amp;&amp; cat <span class="org-string">"/etc/ssl/roots/$HOSTNAME-root.ca"</span> &gt;&gt; <span class="org-string">"/etc/ssl/certs/$HOSTNAME.crt+chain+root"</span>
</pre>
</div>
<p>
Remove the certificate password, so if the server is rebooted then it won't wait indefinitely for a non-existant keyboard user to type in a password.
</p>
<div class="org-src-container">
<pre class="src src-bash">openssl rsa -in /etc/ssl/private/$<span class="org-variable-name">HOSTNAME</span>.key -out /etc/ssl/private/$<span class="org-variable-name">HOSTNAME</span>.new.key
cp /etc/ssl/private/$<span class="org-variable-name">HOSTNAME</span>.new.key /etc/ssl/private/$<span class="org-variable-name">HOSTNAME</span>.key
shred -zu /etc/ssl/private/$<span class="org-variable-name">HOSTNAME</span>.new.key
</pre>
</div>
<p>
Create a bundled certificate which joins the certificate and chain file together.
</p>
<div class="org-src-container">
<pre class="src src-bash">cat /etc/ssl/certs/$<span class="org-variable-name">HOSTNAME</span>.crt /etc/ssl/chains/startssl-sub.class1.server.ca.pem &gt; /etc/ssl/certs/$<span class="org-variable-name">HOSTNAME</span>.bundle.crt
</pre>
</div>
<p>
And also add it to the overall bundle of certificates for the Freedombone. This will allow you to easily install the certificates onto other systems.
</p>
<div class="org-src-container">
<pre class="src src-bash">cp /etc/ssl/certs/$<span class="org-variable-name">HOSTNAME</span>.bundle.crt /etc/ssl/mycerts
cat /etc/ssl/mycerts/*.crt &gt; /etc/ssl/freedombone-bundle.crt
tar -czvf /etc/ssl/freedombone-certs.tar.gz /etc/ssl/mycerts/*.crt
</pre>
</div>
<p>
To avoid any possibility of the certificates being accidentally overwritten by self-signed ones at a later date you can create backups.
</p>
<div class="org-src-container">
<pre class="src src-bash">cp /etc/ssl/certs/$<span class="org-variable-name">HOSTNAME</span>* /etc/ssl/backups/certs/
cp /etc/ssl/private/$<span class="org-variable-name">HOSTNAME</span>* /etc/ssl/backups/private/
chmod -R 400 /etc/ssl/backups/certs/*
chmod -R 400 /etc/ssl/backups/private/*
</pre>
</div>
</div>
</div>
<div id="outline-container-unnumbered-8" class="outline-2">
<h2 id="unnumbered-8">Why use self-signed certificates?</h2>
<div class="outline-text-2" id="text-unnumbered-8">
<p>
Almost everywhere on the web you will read that self-signed certificates are worthless. They bring up scary looking browser warnings and gurus will advise you not to use them. Self-signed certificates are quite useful though. What the scary warnings mean - and it would be good if they explained this more clearly - is that you have an encrypted connection established but there is <i>no certainty about who that connection is with</i>. The usual solution to this is to get a "real" SSL certificate from one of the certificate authorities, but it's far from clear that such authorities can be trusted. There have been various scandals involving such organisations, and it does not seem plausible to assume that they are somehow immune to the sort of treatment which <a href="http://en.wikipedia.org/wiki/Lavabit">Lavabit</a> received. So although most internet users have been trained to look for the lock icon as an indication that the connection is secured that belief may not always be well founded.
</p>
@ -570,17 +719,17 @@ For now a self-signed certificate will probably in most cases protect your commu
</p>
</div>
</div>
<div id="outline-container-unnumbered-8" class="outline-2">
<h2 id="unnumbered-8">Why not use the services of $company instead? They took the Seppuku pledge</h2>
<div class="outline-text-2" id="text-unnumbered-8">
<div id="outline-container-unnumbered-9" class="outline-2">
<h2 id="unnumbered-9">Why not use the services of $company instead? They took the Seppuku pledge</h2>
<div class="outline-text-2" id="text-unnumbered-9">
<p>
<a href="http://seppuku.cryptostorm.org/">That pledge</a> is utterly worthless. Years ago people trusted Google in the same sort of way, because they promised not be be evil and because a lot of the engineers working for them seemed like honest types who were "<i>on our side</i>". Post-<a href="https://en.wikipedia.org/wiki/Nymwars">nymwars</a> and post-<a href="https://en.wikipedia.org/wiki/PRISM_(surveillance_program)">PRISM</a> we know exactly how much Google cared about the privacy and security of its users. But Google is only one particular example. In general don't trust pledges made by companies, even if the people running them seem really sincere.
</p>
</div>
</div>
<div id="outline-container-unnumbered-9" class="outline-2">
<h2 id="unnumbered-9">Why does my email keep getting rejected as spam by Gmail/etc?</h2>
<div class="outline-text-2" id="text-unnumbered-9">
<div id="outline-container-unnumbered-10" class="outline-2">
<h2 id="unnumbered-10">Why does my email keep getting rejected as spam by Gmail/etc?</h2>
<div class="outline-text-2" id="text-unnumbered-10">
<p>
Welcome to the world of email. Email is really the archetypal decentralized service, developed during the early days of the internet. In principle anyone can run an email server, and that's exactly what you're doing with Freedombone. Email is very useful, but it has a big problem, and that's that the protocols are totally insecure. That made it easy for spammers to do their thing, and in response highly elaborate spam filtering and blocking systems were developed. Chances are that your emails are being blocked in this way. Sometimes the blocking is so indisciminate that entire countries are excluded. What can you do about it? Unless you control the block list at the receiving end probably you can't do anything. There is zero accountability for such blocking, and you can't just contact someone and say "hey, I'm not a spammer". This system works well for the big internet companies because it effectively centralises email to a few well-known brand names and keeps any independent servers out.
</p>