source: postlfs/security/cacerts.xml@ afc3f45

10.0 10.1 11.0 11.1 11.2 11.3 12.0 12.1 7.10 7.4 7.5 7.6 7.6-blfs 7.6-systemd 7.7 7.8 7.9 8.0 8.1 8.2 8.3 8.4 9.0 9.1 basic bdubbs/svn elogind gnome kde5-13430 kde5-14269 kde5-14686 kea ken/TL2024 ken/inkscape-core-mods ken/tuningfonts krejzi/svn lazarus lxqt nosym perl-modules plabs/newcss plabs/python-mods python3.11 qt5new rahul/power-profiles-daemon renodr/vulkan-addition systemd-11177 systemd-13485 trunk upgradedb xry111/intltool xry111/llvm18 xry111/soup3 xry111/test-20220226 xry111/xf86-video-removal
Last change on this file since afc3f45 was afc3f45, checked in by Wayne Blaszczyk <wblaszcz@…>, 12 years ago

Fixed wget dependency to Certificate Authority Certificates.

git-svn-id: svn://svn.linuxfromscratch.org/BLFS/trunk/BOOK@8929 af4574ff-66df-0310-9fd7-8a98e5e911e0

  • Property mode set to 100644
File size: 11.2 KB
Line 
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 <bridgehead renderas="sect4">Optional</bridgehead>
64 <para role="optional"><xref linkend="wget"/></para>
65
66 <para condition="html" role="usernotes">User Notes:
67 <ulink url='&blfs-wiki;/cacerts'/></para>
68 </sect2>
69
70 <sect2 role="installation">
71 <title>Installation of Certificate Authority Certificates</title>
72
73 <para>First create a script to reformat a certificate into a
74 form needed by <application>openssl</application>. As the <systemitem
75 class="username">root</systemitem> user:</para>
76
77 <screen><userinput>cat > /bin/make-cert.pl &lt;&lt; "EOF"
78#!/usr/bin/perl -w
79
80# Used to generate PEM encoded files from Mozilla certdata.txt.
81# Run as ./mkcrt.pl > certificate.crt
82#
83# Parts of this script courtesy of RedHat (mkcabundle.pl)
84#
85# This script modified for use with single file data (tempfile.cer) extracted
86# from certdata.txt, taken from the latest version in the Mozilla NSS source.
87# mozilla/security/nss/lib/ckfw/builtins/certdata.txt
88#
89# Authors: DJ Lucas
90# Bruce Dubbs
91
92my $certdata = './tempfile.cer';
93
94open( IN, "cat $certdata|" )
95 || die "could not open $certdata";
96
97my $incert = 0;
98
99while ( &lt;IN&gt; )
100{
101 if ( /^CKA_VALUE MULTILINE_OCTAL/ )
102 {
103 $incert = 1;
104 open( OUT, "|openssl x509 -text -inform DER -fingerprint" )
105 || die "could not pipe to openssl x509";
106 }
107
108 elsif ( /^END/ &amp;&amp; $incert )
109 {
110 close( OUT );
111 $incert = 0;
112 print "\n\n";
113 }
114
115 elsif ($incert)
116 {
117 my @bs = split( /\\/ );
118 foreach my $b (@bs)
119 {
120 chomp $b;
121 printf( OUT "%c", oct($b) ) unless $b eq '';
122 }
123 }
124}
125EOF
126
127chmod +x /bin/make-cert.pl</userinput></screen>
128
129 <para>The following script creates the certificates and a bundle of all the
130 certificates. It creates a <filename class='directory'>./certs</filename>
131 directory and <filename>./BLFS-ca-bundle-${VERSION}.crt</filename>. Again
132 create this script as the <systemitem class="username">root</systemitem>
133 user:</para>
134
135 <screen><userinput>cat > /bin/make-ca.sh &lt;&lt; "EOF"
136#!/bin/bash
137# Begin make-ca.sh
138# Script to populate OpenSSL's CApath from a bundle of PEM formatted CAs
139#
140# The file certdata.txt must exist in the local directory
141# Version number is obtained from the version of the data.
142#
143# Authors: DJ Lucas
144# Bruce Dubbs
145
146certdata="certdata.txt"
147
148if [ ! -r $certdata ]; then
149 echo "$certdata must be in the local directory"
150 exit 1
151fi
152
153REVISION=$(grep CVS_ID $certdata | cut -f4 -d'$')
154
155if [ -z "${REVISION}" ]; then
156 echo "$certfile has no 'Revision' in CVS_ID"
157 exit 1
158fi
159
160VERSION=$(echo $REVISION | cut -f2 -d" ")
161
162TEMPDIR=$(mktemp -d)
163TRUSTATTRIBUTES="CKA_TRUST_SERVER_AUTH"
164BUNDLE="BLFS-ca-bundle-${VERSION}.crt"
165CONVERTSCRIPT="make-cert.pl"
166SSLDIR="/etc/ssl"
167
168mkdir "${TEMPDIR}/certs"
169
170# Get a list of staring lines for each cert
171CERTBEGINLIST=$(grep -n "^# Certificate" "${certdata}" | cut -d ":" -f1)
172
173# Get a list of ending lines for each cert
174CERTENDLIST=`grep -n "^CKA_TRUST_STEP_UP_APPROVED" "${certdata}" | cut -d ":" -f 1`
175
176# Start a loop
177for certbegin in ${CERTBEGINLIST}; do
178 for certend in ${CERTENDLIST}; do
179 if test "${certend}" -gt "${certbegin}"; then
180 break
181 fi
182 done
183
184 # Dump to a temp file with the name of the file as the beginning line number
185 sed -n "${certbegin},${certend}p" "${certdata}" > "${TEMPDIR}/certs/${certbegin}.tmp"
186done
187
188unset CERTBEGINLIST CERTDATA CERTENDLIST certebegin certend
189
190mkdir -p certs
191rm certs/* # Make sure the directory is clean
192
193for tempfile in ${TEMPDIR}/certs/*.tmp; do
194 # Make sure that the cert is trusted...
195 grep "CKA_TRUST_SERVER_AUTH" "${tempfile}" | \
196 grep "CKT_NETSCAPE_TRUST_UNKNOWN" > /dev/null
197
198 if test "${?}" = "0"; then
199 # Throw a meaningful error and remove the file
200 cp "${tempfile}" tempfile.cer
201 "${CONVERTSCRIPT}" > tempfile.crt
202 keyhash=$(openssl x509 -noout -in tempfile.crt -hash)
203 echo "Certificate ${keyhash} is not trusted! Removing..."
204 rm -f tempfile.cer tempfile.crt "${tempfile}"
205 continue
206 fi
207
208 # If execution made it to here in the loop, the temp cert is trusted
209 # Find the cert data and generate a cert file for it
210
211 cp "${tempfile}" tempfile.cer
212 "${CONVERTSCRIPT}" > tempfile.crt
213 keyhash=$(openssl x509 -noout -in tempfile.crt -hash)
214 mv tempfile.crt "certs/${keyhash}.pem"
215 rm -f tempfile.cer "${tempfile}"
216 echo "Created ${keyhash}.pem"
217done
218
219# Remove blacklisted files
220# MD5 Collision Proof of Concept CA
221if test -f certs/8f111d69.pem; then
222 echo "Certificate 8f111d69 is not trusted! Removing..."
223 rm -f certs/8f111d69.pem
224fi
225
226# Finally, generate the bundle and clean up.
227cat certs/*.pem > ${BUNDLE}
228rm -r "${TEMPDIR}"
229EOF
230
231chmod +x /bin/make-ca.sh</userinput></screen>
232
233 <para>Add a short script to remove expired certifictes from a directory.
234 Again create this script as the <systemitem
235 class="username">root</systemitem> user:</para>
236
237 <screen><userinput>cat > /bin/remove-expired-certs.sh &lt;&lt; "EOF"
238#!/bin/bash
239# Begin /bin/remove-expired-certs.sh
240
241OPENSSL=/usr/bin/openssl
242DIR=/etc/ssl/certs
243
244if [ $# -gt 0 ]; then
245 DIR="$1"
246fi
247
248certs=$( find ${DIR} -type f -name "*.pem" -o -name "*.crt" )
249today=$( date +%Y%m%d )
250
251for cert in $certs; do
252 notafter=$( $OPENSSL x509 -enddate -in "${cert}" -noout )
253 date=$( echo ${notafter} | sed 's/^notAfter=//' )
254
255 if [ $( date -d "${date}" +%Y%m%d ) -lt ${today} ]; then
256 echo "${cert} is expired! Removing..."
257 rm -f "${cert}"
258 fi
259done
260EOF
261
262chmod +x /bin/remove-expired-certs.sh</userinput></screen>
263
264 <para>The following commands will fetch the certificates and convert them to
265 the correct format. If desired, a web browser may be used instead of
266 <application>wget</application> but the file will need to be saved with the
267 name <filename>certdata.txt</filename>. These commands can be repeated as
268 necessary to update the CA Certificates.</para>
269
270 <screen><userinput>certhost='http://mxr.mozilla.org' &amp;&amp;
271certdir='/mozilla/source/security/nss/lib/ckfw/builtins' &amp;&amp;
272url="$certhost$certdir/certdata.txt?raw=1" &amp;&amp;
273
274wget --output-document certdata.txt $url &amp;&amp;
275unset certhost certdir url &amp;&amp;
276make-ca.sh &amp;&amp;
277remove-expired-certs.sh certs</userinput></screen>
278
279 <para>Now, as the <systemitem class="username">root</systemitem> user:</para>
280
281<screen><userinput>SSLDIR=/etc/ssl &amp;&amp;
282install -d ${SSLDIR}/certs &amp;&amp;
283cp -v certs/*.pem ${SSLDIR}/certs &amp;&amp;
284c_rehash &amp;&amp;
285install BLFS-ca-bundle*.crt ${SSLDIR}/ca-bundle.crt &amp;&amp;
286unset SSLDIR</userinput></screen>
287
288 <para>Finally, clean up the current directory:</para>
289
290<screen><userinput>rm -r certs BLFS-ca-bundle*</userinput></screen>
291
292 </sect2>
293
294 <sect2 role="content">
295 <title>Contents</title>
296
297 <segmentedlist>
298 <segtitle>Installed Programs</segtitle>
299 <segtitle>Installed Libraries</segtitle>
300 <segtitle>Installed Directories</segtitle>
301
302 <seglistitem>
303 <seg>make-ca.sh, make-cert.pl and remove-expired-certs.sh</seg>
304 <seg>None</seg>
305 <seg>/etc/ssl/certs</seg>
306 </seglistitem>
307 </segmentedlist>
308
309 <variablelist>
310 <bridgehead renderas="sect3">Short Descriptions</bridgehead>
311 <?dbfo list-presentation="list"?>
312 <?dbhtml list-presentation="table"?>
313
314 <varlistentry id="make-ca">
315 <term><command>make-ca.sh</command></term>
316 <listitem>
317 <para>is a <application>bash</application> script that reformats
318 the <filename>certdata.txt</filename> file for use by
319 <application>openssl</application>.</para>
320 <indexterm zone="cacerts make-ca">
321 <primary sortas="b-make-ca">make-ca</primary>
322 </indexterm>
323 </listitem>
324 </varlistentry>
325
326 <varlistentry id="make-cert">
327 <term><command>make-cert.pl</command></term>
328 <listitem>
329 <para>is a utility <application>perl</application> script that
330 converts a single binary certificate (.der format) into .pem format.</para>
331 <indexterm zone="cacerts make-cert">
332 <primary sortas="b-make-cert">make-cert</primary>
333 </indexterm>
334 </listitem>
335 </varlistentry>
336
337 <varlistentry id="remove-expired-certs">
338 <term><command>remove-expired-certs.sh</command></term>
339 <listitem>
340 <para>is a utility <application>perl</application> script that
341 removed expired certificates fom a directory. The defaut
342 directory is <filename class='directory'>/etc/ssl/ceerts</filename>.</para>
343 <indexterm zone="cacerts remove-expired-certs">
344 <primary sortas="b-remove-expired-certs">remove-expired-certs</primary>
345 </indexterm>
346 </listitem>
347 </varlistentry>
348 </variablelist>
349
350 </sect2>
351</sect1>
Note: See TracBrowser for help on using the repository browser.