<?xml version="1.0" encoding="utf-8"?><!DOCTYPE article  PUBLIC '-//OASIS//DTD DocBook XML V4.4//EN'  'http://www.docbook.org/xml/4.4/docbookx.dtd'><article><articleinfo><title>DomTool/SslProcedures</title><revhistory><revision><revnumber>11</revnumber><date>2014-04-24 02:05:48</date><authorinitials>ClintonEbadi</authorinitials><revremark>dead link</revremark></revision><revision><revnumber>10</revnumber><date>2014-02-16 23:04:42</date><authorinitials>ClintonEbadi</authorinitials><revremark>warn users away from the guts of domtool and toward more relevant documentation</revremark></revision><revision><revnumber>9</revnumber><date>2012-06-17 07:06:55</date><authorinitials>ClintonEbadi</authorinitials><revremark>document the domtool Trust Store</revremark></revision><revision><revnumber>8</revnumber><date>2010-02-16 18:11:11</date><authorinitials>DavorOcelic</authorinitials></revision><revision><revnumber>7</revnumber><date>2010-02-16 18:07:14</date><authorinitials>DavorOcelic</authorinitials></revision><revision><revnumber>6</revnumber><date>2009-12-01 17:57:40</date><authorinitials>AdamChlipala</authorinitials><revremark>Update inline code mark-up</revremark></revision><revision><revnumber>5</revnumber><date>2008-07-07 04:28:17</date><authorinitials>localhost</authorinitials><revremark>converted to 1.6 markup</revremark></revision><revision><revnumber>4</revnumber><date>2006-12-16 22:09:16</date><authorinitials>AdamChlipala</authorinitials></revision><revision><revnumber>3</revnumber><date>2006-12-16 19:50:04</date><authorinitials>AdamChlipala</authorinitials><revremark>Warn about unique_subject</revremark></revision><revision><revnumber>2</revnumber><date>2006-12-09 16:48:51</date><authorinitials>AdamChlipala</authorinitials><revremark>No passphrase for server keys</revremark></revision><revision><revnumber>1</revnumber><date>2006-12-09 00:57:39</date><authorinitials>AdamChlipala</authorinitials></revision></revhistory></articleinfo><caution><para>The SSL certification authority and related certificates discussed here are used by <ulink url="https://wiki.hcoop.net/DomTool/SslProcedures/DomTool/ArchitectureOverview#Users_and_authentication">domtool for authentication</ulink>, and are not in any way related to administering the web server <ulink url="https://wiki.hcoop.net/DomTool/SslProcedures/CertificateAuthority#">CertificateAuthority</ulink> or to <ulink url="https://wiki.hcoop.net/DomTool/SslProcedures/MemberManual/ServingWebsites/SslCert#">using SSL on a hosted website</ulink>. </para></caution><para><emphasis role="strong">Note</emphasis>: You can generally avoid worrying about these details by using the scripts described in <ulink url="https://wiki.hcoop.net/DomTool/SslProcedures/DomTool/AdminProcedures#">DomTool/AdminProcedures</ulink>. The instructions here are mostly of interest to people implementing those scripts. </para><para>These instructions assume you are running as a user in group <code>wheel</code> on <code>deleuze.hcoop.net</code>. </para><section><title>Creating a certificate authority</title><para>I followed the instructions on this page: </para><itemizedlist><listitem override="none"><para><ulink url="https://web.archive.org/web/20081220135010/http://sial.org/howto/openssl/ca/">http://sial.org/howto/openssl/ca/</ulink> </para></listitem></itemizedlist><para>This blog post revealed the source of a puzzling error: </para><itemizedlist><listitem override="none"><para><ulink url="http://ilovett.com/blog/projects/debian-apache-ssl"/> </para></listitem></itemizedlist><para>It turns out leaving some fields (like the city name for your new certificate) blank leads to baffling messages! </para><para>Extracting the relevant commands from the Makefile available at the former page, we run these commands to create our CA: </para><screen><![CDATA[mkdir -p /etc/domtool/ca
cd /etc/domtool/ca
mkdir crl newcerts private
chmod go-rwx private
echo '01' > serial
touch index
]]><![CDATA[
cd ..
# NOTE remove ":2048" below if running OpenSSL lower than 0.9.8a
openssl req -nodes -config openssl.conf -days 1825 -x509 -newkey rsa:2048 -out ca/ca-cert.pem -outform PEM]]></screen><para><emphasis role="strong">(NOTE: remove the &quot;o&quot; from all openssl.conf when running all commands (above and below); I used .conf just because wiki anti-spam methods do not allow .c-n-f (no comment)).</emphasis> </para><para>Now the directory structure of our CA exists, and we have the certificate we will use to sign certificates. </para><para>After creating the CA, dump its certificate to <ulink url="https://wiki.hcoop.net/DomTool/SslProcedures/DomTool#">DomTool</ulink>'s trust store (see <code>trustStore</code> configuration value for the location). If you are creating a new CA (e.g. the domtool CA was compromised, or the private key otherwise leaked or destroyed) make sure to remove the invalid CA certificate from this file. </para><screen><![CDATA[cat /etc/domtool/ca/ca-cert.pem >> ${LOCATION OF TRUST STORE}]]></screen></section><section><title>Creating a certificate for a node or user</title><para>I followed the instructions on these pages: </para><itemizedlist><listitem override="none"><para><ulink url="http://marc.theaimsgroup.com/?l=openssl-users&amp;m=97049654211960&amp;w=2"/> </para><para><ulink url="http://www.postgresql.org/docs/8.1/interactive/ssl-tcp.html"/> </para></listitem></itemizedlist><para>The commands to run are: </para><screen><![CDATA[openssl genrsa -out serverkey.pem
openssl req -new -key serverkey.pem -out newreq.pem -days 365
cat newreq.pem serverkey.pem > new.pem
openssl ca -config /etc/domtool/openssl.conf -policy policy_anything -out servercert.pem -infiles new.pem]]></screen><para>replacing <code>serverkey.pem</code> and <code>servercert.pem</code> with appropriate names for your new key and certificate, respectively.  The change I made from <ulink url="http://marc.theaimsgroup.com/?l=openssl-users&amp;m=97049654211960&amp;w=2">the cited source</ulink> is to include the <code>-config</code> flag to reference the modified config file obtained from <ulink url="http://sial.org/howto/openssl/ca/">the page about creating a CA</ulink>. </para><para>Once I figure out the final directory layout, there will be instructions here on where to put these files once they're created. </para></section><section><title>Baffling things that can happen</title><para>If <code>openssl ca</code> tells you this: </para><screen><![CDATA[failed to update database
TXT_DB error number 2]]></screen><para>it means that you have it configured not to sign a certificate for the same user multiple times, but you've gone ahead and asked it to do so anyway.  Add this line to the section for your default CA in <code>openssl.conf</code>: </para><screen><![CDATA[unique_subject = no]]></screen><para>If you've already been signing some keys and you want to keep what you've done so far, you may also need to make similar changes in <code>index.attr</code> and possibly <code>index.attr.old</code>. </para></section></article>