[c9b953e6] | 1 | <?xml version="1.0" encoding="ISO-8859-1"?>
|
---|
| 2 | <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
|
---|
| 3 | "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
|
---|
| 4 | <!ENTITY % general-entities SYSTEM "../../general.ent">
|
---|
| 5 | %general-entities;
|
---|
| 6 |
|
---|
| 7 | <!ENTITY certhost "http://mxr.mozilla.org">
|
---|
| 8 | <!ENTITY certdir "/mozilla/source/security/nss/lib/ckfw/builtins">
|
---|
| 9 | <!ENTITY ca-bundle-download "&certhost;&certdir;/certdata.txt?raw=1">
|
---|
| 10 | <!ENTITY ca-bundle-size "1.2 MB">
|
---|
| 11 | <!ENTITY cacerts-buildsize "1.2 MB">
|
---|
| 12 | <!ENTITY cacerts-time "less than 0.1 SBU">
|
---|
| 13 | ]>
|
---|
| 14 |
|
---|
| 15 | <sect1 id="cacerts" xreflabel="Certificate Authority Certificates">
|
---|
| 16 | <?dbhtml filename="cacerts.html"?>
|
---|
| 17 |
|
---|
| 18 | <sect1info>
|
---|
| 19 | <othername>$LastChangedBy$</othername>
|
---|
| 20 | <date>$Date$</date>
|
---|
| 21 | </sect1info>
|
---|
| 22 |
|
---|
| 23 | <title>Certificate Authority Certificates</title>
|
---|
| 24 |
|
---|
| 25 | <para>The Public Key Inrastructure is used for many security issues in a
|
---|
| 26 | Linux system. In order for a certificate to be trusted, it must be signed by
|
---|
| 27 | a trusted agent called a Certificate Authority (CA). The certificates loaded
|
---|
| 28 | by this section are from the list on the Mozilla version control system and
|
---|
| 29 | formats it into a form used by <xref linkend='openssl'/>. The certificates
|
---|
| 30 | can also be used by other applications either directly of indirectly through
|
---|
| 31 | <application>openssl</application>.</para>
|
---|
| 32 |
|
---|
| 33 | &lfs70_checked;
|
---|
| 34 |
|
---|
| 35 | <indexterm zone="cacerts">
|
---|
| 36 | <primary sortas="a-cacerts">Certificate Authority Certificates</primary>
|
---|
| 37 | </indexterm>
|
---|
| 38 |
|
---|
| 39 | <sect2 role="package">
|
---|
| 40 | <title>Introduction to Certificate Authorities</title>
|
---|
| 41 |
|
---|
| 42 | <bridgehead renderas="sect3">Package Information</bridgehead>
|
---|
| 43 | <itemizedlist spacing="compact">
|
---|
| 44 | <listitem>
|
---|
| 45 | <para>CA Certificate Download: <ulink url="&ca-bundle-download;"/></para>
|
---|
| 46 | </listitem>
|
---|
| 47 | <listitem>
|
---|
| 48 | <para>CA Bundle size: &ca-bundle-size;</para>
|
---|
| 49 | </listitem>
|
---|
| 50 | <listitem>
|
---|
| 51 | <para>Estimated disk space required: &cacerts-buildsize;</para>
|
---|
| 52 | </listitem>
|
---|
| 53 | <listitem>
|
---|
| 54 | <para>Estimated build time: &cacerts-time;</para>
|
---|
| 55 | </listitem>
|
---|
| 56 | </itemizedlist>
|
---|
| 57 |
|
---|
| 58 | <bridgehead renderas="sect3">Certificate Authority Certificates Dependencies</bridgehead>
|
---|
| 59 |
|
---|
| 60 | <bridgehead renderas="sect4">Required</bridgehead>
|
---|
| 61 | <para role="required"><xref linkend="openssl"/></para>
|
---|
| 62 |
|
---|
| 63 | <para condition="html" role="usernotes">User Notes:
|
---|
| 64 | <ulink url='&blfs-wiki;/cacerts'/></para>
|
---|
| 65 | </sect2>
|
---|
| 66 |
|
---|
| 67 | <sect2 role="installation">
|
---|
| 68 | <title>Installation of Certificate Authority Certificates</title>
|
---|
| 69 |
|
---|
| 70 | <para>First create a script to reformat a certificate into a
|
---|
| 71 | form needed by <application>openssl</application>. As the <systemitem
|
---|
| 72 | class="username">root</systemitem> user:</para>
|
---|
| 73 |
|
---|
| 74 | <screen><userinput>cat > /bin/make-cert.pl << "EOF"
|
---|
| 75 | #!/usr/bin/perl -w
|
---|
| 76 |
|
---|
| 77 | # Used to generate PEM encoded files from Mozilla certdata.txt.
|
---|
| 78 | # Run as ./mkcrt.pl > certificate.crt
|
---|
| 79 | #
|
---|
| 80 | # Parts of this script courtesy of RedHat (mkcabundle.pl)
|
---|
| 81 | #
|
---|
| 82 | # This script modified for use with single file data (tempfile.cer) extracted
|
---|
| 83 | # from certdata.txt, taken from the latest version in the Mozilla NSS source.
|
---|
| 84 | # mozilla/security/nss/lib/ckfw/builtins/certdata.txt
|
---|
| 85 | #
|
---|
| 86 | # Authors: DJ Lucas
|
---|
| 87 | # Bruce Dubbs
|
---|
| 88 |
|
---|
| 89 | my $certdata = './tempfile.cer';
|
---|
| 90 |
|
---|
| 91 | open( IN, "cat $certdata|" )
|
---|
| 92 | || die "could not open $certdata";
|
---|
| 93 |
|
---|
| 94 | my $incert = 0;
|
---|
| 95 |
|
---|
| 96 | while ( <IN> )
|
---|
| 97 | {
|
---|
| 98 | if ( /^CKA_VALUE MULTILINE_OCTAL/ )
|
---|
| 99 | {
|
---|
| 100 | $incert = 1;
|
---|
| 101 | open( OUT, "|openssl x509 -text -inform DER -fingerprint" )
|
---|
| 102 | || die "could not pipe to openssl x509";
|
---|
| 103 | }
|
---|
| 104 |
|
---|
| 105 | elsif ( /^END/ && $incert )
|
---|
| 106 | {
|
---|
| 107 | close( OUT );
|
---|
| 108 | $incert = 0;
|
---|
| 109 | print "\n\n";
|
---|
| 110 | }
|
---|
| 111 |
|
---|
| 112 | elsif ($incert)
|
---|
| 113 | {
|
---|
| 114 | my @bs = split( /\\/ );
|
---|
| 115 | foreach my $b (@bs)
|
---|
| 116 | {
|
---|
| 117 | chomp $b;
|
---|
| 118 | printf( OUT "%c", oct($b) ) unless $b eq '';
|
---|
| 119 | }
|
---|
| 120 | }
|
---|
| 121 | }
|
---|
| 122 | EOF
|
---|
| 123 |
|
---|
| 124 | chmod +x /bin/make-cert.pl</userinput></screen>
|
---|
| 125 |
|
---|
| 126 | <para>The following script creates the certificates and a bundle of all the
|
---|
| 127 | certificates. It creates a <filename class='directory'>./certs</filename>
|
---|
| 128 | directory and <filename>./BLFS-ca-bundle-${VERSION}.crt</filename>. Again
|
---|
| 129 | create this script as the <systemitem class="username">root</systemitem>
|
---|
| 130 | user:</para>
|
---|
| 131 |
|
---|
| 132 | <screen><userinput>cat > /bin/make-ca.sh << "EOF"
|
---|
| 133 | #!/bin/bash
|
---|
| 134 | # Begin make-ca.sh
|
---|
| 135 | # Script to populate OpenSSL's CApath from a bundle of PEM formatted CAs
|
---|
| 136 | #
|
---|
| 137 | # The file certdata.txt must exist in the local directory
|
---|
| 138 | # Version number is obtained from the version of the data.
|
---|
| 139 | #
|
---|
| 140 | # Authors: DJ Lucas
|
---|
| 141 | # Bruce Dubbs
|
---|
| 142 |
|
---|
| 143 | certdata="certdata.txt"
|
---|
| 144 |
|
---|
| 145 | if [ ! -r $certdata ]; then
|
---|
| 146 | echo "$certdata must be in the local directory"
|
---|
| 147 | exit 1
|
---|
| 148 | fi
|
---|
| 149 |
|
---|
| 150 | REVISION=$(grep CVS_ID $certdata | cut -f4 -d'$')
|
---|
| 151 |
|
---|
| 152 | if [ -z "${REVISION}" ]; then
|
---|
| 153 | echo "$certfile has no 'Revision' in CVS_ID"
|
---|
| 154 | exit 1
|
---|
| 155 | fi
|
---|
| 156 |
|
---|
| 157 | VERSION=$(echo $REVISION | cut -f2 -d" ")
|
---|
| 158 |
|
---|
| 159 | TEMPDIR=$(mktemp -d)
|
---|
| 160 | TRUSTATTRIBUTES="CKA_TRUST_SERVER_AUTH"
|
---|
| 161 | BUNDLE="BLFS-ca-bundle-${VERSION}.crt"
|
---|
| 162 | CONVERTSCRIPT="make-cert.pl"
|
---|
| 163 | SSLDIR="/etc/ssl"
|
---|
| 164 |
|
---|
| 165 | mkdir "${TEMPDIR}/certs"
|
---|
| 166 |
|
---|
| 167 | # Get a list of staring lines for each cert
|
---|
| 168 | CERTBEGINLIST=$(grep -n "^# Certificate" "${certdata}" | cut -d ":" -f1)
|
---|
| 169 |
|
---|
| 170 | # Get a list of ending lines for each cert
|
---|
| 171 | CERTENDLIST=`grep -n "^CKA_TRUST_STEP_UP_APPROVED" "${certdata}" | cut -d ":" -f 1`
|
---|
| 172 |
|
---|
| 173 | # Start a loop
|
---|
| 174 | for certbegin in ${CERTBEGINLIST}; do
|
---|
| 175 | for certend in ${CERTENDLIST}; do
|
---|
| 176 | if test "${certend}" -gt "${certbegin}"; then
|
---|
| 177 | break
|
---|
| 178 | fi
|
---|
| 179 | done
|
---|
| 180 |
|
---|
| 181 | # Dump to a temp file with the name of the file as the beginning line number
|
---|
| 182 | sed -n "${certbegin},${certend}p" "${certdata}" > "${TEMPDIR}/certs/${certbegin}.tmp"
|
---|
| 183 | done
|
---|
| 184 |
|
---|
| 185 | unset CERTBEGINLIST CERTDATA CERTENDLIST certebegin certend
|
---|
| 186 |
|
---|
| 187 | mkdir -p certs
|
---|
| 188 | rm certs/* # Make sure the directory is clean
|
---|
| 189 |
|
---|
| 190 | for tempfile in ${TEMPDIR}/certs/*.tmp; do
|
---|
| 191 | # Make sure that the cert is trusted...
|
---|
| 192 | grep "CKA_TRUST_SERVER_AUTH" "${tempfile}" | \
|
---|
| 193 | grep "CKT_NETSCAPE_TRUST_UNKNOWN" > /dev/null
|
---|
| 194 |
|
---|
| 195 | if test "${?}" = "0"; then
|
---|
| 196 | # Throw a meaningful error and remove the file
|
---|
| 197 | cp "${tempfile}" tempfile.cer
|
---|
| 198 | "${CONVERTSCRIPT}" > tempfile.crt
|
---|
| 199 | keyhash=$(openssl x509 -noout -in tempfile.crt -hash)
|
---|
| 200 | echo "Certificate ${keyhash} is not trusted! Removing..."
|
---|
| 201 | rm -f tempfile.cer tempfile.crt "${tempfile}"
|
---|
| 202 | continue
|
---|
| 203 | fi
|
---|
| 204 |
|
---|
| 205 | # If execution made it to here in the loop, the temp cert is trusted
|
---|
| 206 | # Find the cert data and generate a cert file for it
|
---|
| 207 |
|
---|
| 208 | cp "${tempfile}" tempfile.cer
|
---|
| 209 | "${CONVERTSCRIPT}" > tempfile.crt
|
---|
| 210 | keyhash=$(openssl x509 -noout -in tempfile.crt -hash)
|
---|
| 211 | mv tempfile.crt "certs/${keyhash}.pem"
|
---|
| 212 | rm -f tempfile.cer "${tempfile}"
|
---|
| 213 | echo "Created ${keyhash}.pem"
|
---|
| 214 | done
|
---|
| 215 |
|
---|
| 216 | # Remove blacklisted files
|
---|
| 217 | # MD5 Collision Proof of Concept CA
|
---|
| 218 | if test -f certs/8f111d69.pem; then
|
---|
| 219 | echo "Certificate 8f111d69 is not trusted! Removing..."
|
---|
| 220 | rm -f certs/8f111d69.pem
|
---|
| 221 | fi
|
---|
| 222 |
|
---|
| 223 | # Finally, generate the bundle and clean up.
|
---|
| 224 | cat certs/*.pem > ${BUNDLE}
|
---|
| 225 | rm -r "${TEMPDIR}"
|
---|
| 226 | EOF
|
---|
| 227 |
|
---|
| 228 | chmod +x /bin/make-ca.sh</userinput></screen>
|
---|
| 229 |
|
---|
| 230 | <para>The following commands will fetch the certificates and convert them to
|
---|
| 231 | the correct format. If desired, a web browser may be used instead of
|
---|
| 232 | <application>wget</application> but the file will need to be saved with the
|
---|
| 233 | name <filename>certdata.txt</filename>. These commands can be repeated as
|
---|
| 234 | necessary to update the CA Certificates.</para>
|
---|
| 235 |
|
---|
| 236 | <screen><userinput>certhost='http://mxr.mozilla.org' &&
|
---|
| 237 | certdir='/mozilla/source/security/nss/lib/ckfw/builtins' &&
|
---|
| 238 | url="$certhost$certdir/certdata.txt?raw=1" &&
|
---|
| 239 |
|
---|
| 240 | wget --output-document certdata.txt $url &&
|
---|
| 241 | unset certhost certdir url &&
|
---|
| 242 | make-ca.sh</userinput></screen>
|
---|
| 243 |
|
---|
| 244 | <para>Now, as the <systemitem class="username">root</systemitem> user:</para>
|
---|
| 245 |
|
---|
| 246 | <screen><userinput>install -d ${SSLDIR}/certs &&
|
---|
| 247 | cp -v certs/*.pem ${SSLDIR}/certs &&
|
---|
| 248 | c_rehash &&
|
---|
| 249 | install ca-bundle.crt ${SSLDIR}</userinput></screen>
|
---|
| 250 |
|
---|
| 251 | <para>Finally, clean up the current directory:</para>
|
---|
| 252 |
|
---|
| 253 | <screen><userinput>rm -r certs BLFS-ca-bundle*</userinput></screen>
|
---|
| 254 |
|
---|
| 255 | </sect2>
|
---|
| 256 |
|
---|
| 257 | <sect2 role="content">
|
---|
| 258 | <title>Contents</title>
|
---|
| 259 |
|
---|
| 260 | <segmentedlist>
|
---|
| 261 | <segtitle>Installed Programs</segtitle>
|
---|
| 262 | <segtitle>Installed Libraries</segtitle>
|
---|
| 263 | <segtitle>Installed Directories</segtitle>
|
---|
| 264 |
|
---|
| 265 | <seglistitem>
|
---|
| 266 | <seg>make-ca.sh and make-cert.pl</seg>
|
---|
| 267 | <seg>None</seg>
|
---|
| 268 | <seg>/etc/ssl/certs</seg>
|
---|
| 269 | </seglistitem>
|
---|
| 270 | </segmentedlist>
|
---|
| 271 |
|
---|
| 272 | <variablelist>
|
---|
| 273 | <bridgehead renderas="sect3">Short Descriptions</bridgehead>
|
---|
| 274 | <?dbfo list-presentation="list"?>
|
---|
| 275 | <?dbhtml list-presentation="table"?>
|
---|
| 276 |
|
---|
| 277 | <varlistentry id="make-ca">
|
---|
| 278 | <term><command>make-ca.sh</command></term>
|
---|
| 279 | <listitem>
|
---|
| 280 | <para>is a <application>bash</application> script that reformats
|
---|
| 281 | the <filename>certdata.txt</filename> file for use by
|
---|
| 282 | <application>openssl</application>.</para>
|
---|
| 283 | <indexterm zone="cacerts make-ca">
|
---|
| 284 | <primary sortas="b-make-ca">make-ca</primary>
|
---|
| 285 | </indexterm>
|
---|
| 286 | </listitem>
|
---|
| 287 | </varlistentry>
|
---|
| 288 |
|
---|
| 289 | <varlistentry id="make-cert">
|
---|
| 290 | <term><command>make-cert.pl</command></term>
|
---|
| 291 | <listitem>
|
---|
| 292 | <para>is a utility <application>perl</application> script that
|
---|
| 293 | converts a single binary certificate (.der format) into .pem format.</para>
|
---|
| 294 | <indexterm zone="cacerts make-cert">
|
---|
| 295 | <primary sortas="b-make-cert">make-cert</primary>
|
---|
| 296 | </indexterm>
|
---|
| 297 | </listitem>
|
---|
| 298 | </varlistentry>
|
---|
| 299 | </variablelist>
|
---|
| 300 |
|
---|
| 301 | </sect2>
|
---|
| 302 | </sect1>
|
---|