source: postlfs/security/make-ca.xml@ 21114f6

12.0 12.1 kea ken/TL2024 ken/tuningfonts lazarus lxqt plabs/newcss python3.11 qt5new rahul/power-profiles-daemon renodr/vulkan-addition trunk xry111/llvm18 xry111/xf86-video-removal
Last change on this file since 21114f6 was 21114f6, checked in by Xi Ruoyao <xry111@…>, 13 months ago

make-ca: Mark p11-kit again as runtime, and ...

add a note about running make-ca itself in the installation section.

  • Property mode set to 100644
File size: 16.6 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 "https://hg.mozilla.org/">
8 <!ENTITY certpath "/lib/ckfw/builtins/certdata.txt">
9 <!ENTITY make-ca-buildsize "6.9 MB (with all runtime deps)">
10 <!ENTITY make-ca-time "0.1 SBU (with all runtime deps)">
11
12 <!ENTITY make-ca-download "https://github.com/lfs-book/make-ca/releases/download/v&make-ca-version;/make-ca-&make-ca-version;.tar.xz">
13 <!ENTITY make-ca-size "36 KB">
14 <!ENTITY make-ca-md5sum "67e0b911e73a859fc326171c5153d455">
15]>
16
17<sect1 id="make-ca" xreflabel="make-ca-&make-ca-version;">
18 <?dbhtml filename="make-ca.html"?>
19
20
21 <title>make-ca-&make-ca-version;</title>
22 <indexterm zone="make-ca">
23 <primary sortas="a-make-ca">make-ca</primary>
24 </indexterm>
25
26 <sect2 role="package">
27 <title>Introduction to make-ca</title>
28
29 <para>
30 Public Key Infrastructure (PKI) is a method to validate the authenticity
31 of an otherwise unknown entity across untrusted networks. PKI works by
32 establishing a chain of trust, rather than trusting each individual host
33 or entity explicitly. In order for a certificate presented by a remote
34 entity to be trusted, that certificate must present a complete chain of
35 certificates that can be validated using the root certificate of a
36 Certificate Authority (CA) that is trusted by the local machine.
37 </para>
38
39 <para>
40 Establishing trust with a CA involves validating things like company
41 address, ownership, contact information, etc., and ensuring that the CA
42 has followed best practices, such as undergoing periodic security audits
43 by independent investigators and maintaining an always available
44 certificate revocation list. This is well outside the scope of BLFS (as
45 it is for most Linux distributions). The certificate store provided here
46 is taken from the Mozilla Foundation, who have established very strict
47 inclusion policies described <ulink
48 url="https://www.mozilla.org/en-US/about/governance/policies/security-group/certs/">here</ulink>.
49 </para>
50
51 &lfs113_checked;
52
53 <bridgehead renderas="sect3">Package Information</bridgehead>
54 <itemizedlist spacing="compact">
55 <listitem>
56 <para>
57 Download (HTTP): <ulink url="&make-ca-download;"/>
58 </para>
59 </listitem>
60 <listitem>
61 <para>
62 Download size: &make-ca-size;
63 </para>
64 </listitem>
65 <listitem>
66 <para>
67 Download MD5 Sum: &make-ca-md5sum;
68 </para>
69 </listitem>
70 <listitem>
71 <para>
72 Estimated disk space required: &make-ca-buildsize;
73 </para>
74 </listitem>
75 <listitem>
76 <para>
77 Estimated build time: &make-ca-time;
78 </para>
79 </listitem>
80 </itemizedlist>
81
82 <bridgehead renderas="sect3">make-ca Dependencies</bridgehead>
83
84 <bridgehead renderas="sect4">Required</bridgehead>
85 <para role="required">
86 <!-- Attention: no role="runtime" here because jhalfs don't assume
87 runtime dependencies are needed to run commands. -->
88 <xref linkend="p11-kit"/> (runtime, built after
89 <xref role="nodep" linkend="libtasn1"/>, required in the following
90 instructions to generate certificate stores from trust anchors, and
91 each time <command>make-ca</command> is run)
92 </para>
93 <!-- /usr/bin/trust is needed to extract the certs to /etc/ssl/certs -->
94
95 <bridgehead renderas="sect4">Optional (runtime)</bridgehead>
96 <para role="optional">
97 <xref role="runtime" linkend="nss"/> (to generate a shared NSSDB)
98 </para>
99
100 <para condition="html" role="usernotes">User Notes:
101 <ulink url='&blfs-wiki;/make-ca'/></para>
102 </sect2>
103
104 <sect2 role="installation">
105 <title>Installation of make-ca and Generation of the CA-certificates stores</title>
106
107 <para>
108 The <application>make-ca</application> script will download and process
109 the certificates included in the <filename>certdata.txt</filename> file
110 for use as trust anchors for the <xref linkend="p11-kit"/> trust module.
111 Additionally, it will generate system certificate stores used by BLFS
112 applications (if the recommended and optional applications are present
113 on the system). Any local certificates stored in
114 <filename>/etc/ssl/local</filename> will be imported to both the trust
115 anchors and the generated certificate stores (overriding Mozilla's
116 trust). Additionally, any modified trust values will be copied from the
117 trust anchors to <filename>/etc/ssl/local</filename> prior to any
118 updates, preserving custom trust values that differ from Mozilla when
119 using the <command>trust</command> utility from
120 <application>p11-kit</application> to operate on the trust store.
121 </para>
122
123 <para>
124 To install the various certificate stores, first install the
125 <application>make-ca</application> script into the correct location.
126 As the <systemitem class="username">root</systemitem> user:
127 </para>
128
129<screen role="root"><userinput>make install &amp;&amp;
130install -vdm755 /etc/ssl/local</userinput></screen>
131
132 <note>
133 <para>
134 Technically, this package is already installed at this point.
135 But most packages listing <application>make-ca</application> as
136 a dependency actually requires the system certificate store set up
137 by this package, instead of requiring the <command>make-ca</command>
138 program itself. So the instructions for using
139 <command>make-ca</command> for setting up the system certificate
140 store is included in this section. You should make sure the required
141 runtime dependency for <application>make-ca</application> is
142 satisified now, and continue to follow the instructions.
143 </para>
144 </note>
145
146 <para>
147 As the <systemitem class="username">root</systemitem> user,
148 download the certificate source and
149 prepare for system use with the following command:
150 </para>
151
152 <note>
153 <para>
154 If running the script a second time with the same version of
155 <filename>certdata.txt</filename>, for instance, to update the
156 stores when <application>make-ca</application> is upgraded, or to
157 add additional stores as the requisite software is installed,
158 replace the <parameter>-g</parameter> switch with the
159 <parameter>-r</parameter> switch in the command line. If packaging,
160 run <command>make-ca --help</command> to see all available command
161 line options.
162 </para>
163 </note>
164
165<screen role="root"><userinput>/usr/sbin/make-ca -g</userinput></screen>
166
167 <para>
168 You should periodically update the store with the above command,
169 either manually, or via a <phrase revision="sysv">cron job.</phrase>
170 <phrase revision="systemd">systemd timer. A timer is installed at
171 <filename>/usr/lib/systemd/system/update-pki.timer</filename> that, if
172 enabled, will check for updates weekly.</phrase><phrase
173 revision="sysv">If you've installed <xref linkend="fcron"/> and
174 completed the section on periodic jobs, execute</phrase> <phrase
175 revision="systemd">Execute</phrase> the following commands, as the
176 <systemitem class="username">root</systemitem> user, to <phrase
177 revision="sysv">create a weekly cron job:</phrase><phrase
178 revision="systemd">enable the systemd timer:</phrase>
179 </para>
180
181<screen role="nodump" revision="sysv"><userinput>cat &gt; /etc/cron.weekly/update-pki.sh &lt;&lt; "EOF" &amp;&amp;
182<literal>#!/bin/bash
183/usr/sbin/make-ca -g</literal>
184EOF
185chmod 754 /etc/cron.weekly/update-pki.sh</userinput></screen>
186
187<screen role="root" revision="systemd"><userinput>systemctl enable update-pki.timer</userinput></screen>
188
189 </sect2>
190
191 <sect2 role="configuration" id="make-ca-config">
192 <title>Configuring make-ca</title>
193
194 <para>
195 For most users, no additional configuration is necessary, however,
196 the default <filename>certdata.txt</filename> file provided by make-ca
197 is obtained from the mozilla-release branch, and is modified to provide a
198 Mercurial revision. This will be the correct version for most systems.
199 There are several other variants of the file available for use that might
200 be preferred for one reason or another, including the files shipped with
201 Mozilla products in this book. RedHat and OpenSUSE, for instance, use the
202 version included in <xref linkend="nss"/>. Additional upstream downloads
203 are available at the links included in
204 <filename>/etc/make-ca/make-ca.conf.dist</filename>. Simply copy the
205 file to
206 <filename>/etc/make-ca.conf</filename> and edit as appropriate.
207 </para>
208
209 <indexterm zone="make-ca make-ca-config">
210 <primary sortas="e-etc-make-ca-conf">/etc/make-ca.conf</primary>
211 </indexterm>
212
213 <bridgehead renderas="sect3">About Trust Arguments</bridgehead>
214
215 <para>
216 There are three trust types that are recognized by the
217 <application>make-ca</application> script, SSL/TLS, S/Mime, and code
218 signing. For <application>OpenSSL</application>, these are
219 <parameter>serverAuth</parameter>,
220 <parameter>emailProtection</parameter>, and
221 <parameter>codeSigning</parameter> respectively. If one of the three
222 trust arguments is omitted, the certificate is neither trusted, nor
223 rejected for that role. Clients that use
224 <application>OpenSSL</application> or <application>NSS</application>
225 encountering this certificate will present a warning to the user.
226 Clients using
227 <application>GnuTLS</application> without
228 <application>p11-kit</application> support are not aware of trusted
229 certificates. To include this CA into the
230 <filename>ca-bundle.crt</filename>,
231 <filename>email-ca-bundle.crt</filename>, or
232 <filename>objsign-ca-bundle.crt</filename> files
233 (the <application>GnuTLS</application> legacy bundles), it must have the
234 appropriate trust arguments.
235 </para>
236
237 <bridgehead renderas="sect3">Adding Additional CA Certificates</bridgehead>
238
239 <para>
240 The <filename class="directory">/etc/ssl/local</filename> directory
241 is available to add additional CA certificates to the system trust store.
242 This directory is also used to store certificates that were added to or
243 modified in the system trust store by <xref linkend="p11-kit"/> so that
244 trust values are maintained across upgrades. Files in this directory must
245 be in the <application>OpenSSL</application> trusted certificate format.
246 Certificates imported using the <command>trust</command> utility from
247 <xref linkend="p11-kit"/> will utilize the x509 Extended Key Usage values
248 to assign default trust values for the system anchors.
249 </para>
250
251 <para>If you need to override trust values, or otherwise need to create
252 an <application>OpenSSL</application> trusted certificate manually
253 from a regular PEM encoded file, you need to add trust arguments to the
254 <command>openssl</command> command, and create a new certificate. For
255 example, using the <ulink url="http://www.cacert.org/">CAcert</ulink>
256 roots, if you want to trust both for all three roles, the following
257 commands will create appropriate OpenSSL trusted certificates (run as
258 the <systemitem class="username">root</systemitem> user after <xref
259 linkend="wget"/> is installed):
260 </para>
261
262<screen role="nodump"><userinput>wget http://www.cacert.org/certs/root.crt &amp;&amp;
263wget http://www.cacert.org/certs/class3.crt &amp;&amp;
264openssl x509 -in root.crt -text -fingerprint -setalias "CAcert Class 1 root" \
265 -addtrust serverAuth -addtrust emailProtection -addtrust codeSigning \
266 > /etc/ssl/local/CAcert_Class_1_root.pem &amp;&amp;
267openssl x509 -in class3.crt -text -fingerprint -setalias "CAcert Class 3 root" \
268 -addtrust serverAuth -addtrust emailProtection -addtrust codeSigning \
269 > /etc/ssl/local/CAcert_Class_3_root.pem &amp;&amp;
270/usr/sbin/make-ca -r</userinput></screen>
271
272 <bridgehead renderas="sect3">Overriding Mozilla Trust</bridgehead>
273
274 <para>
275 Occasionally, there may be instances where you don't agree with
276 Mozilla's inclusion of a particular certificate authority. If you'd like
277 to override the default trust of a particular CA, simply create a copy of
278 the existing certificate in <filename
279 class="directory">/etc/ssl/local</filename> with different trust
280 arguments. For example, if you'd like to distrust the
281 "Makebelieve_CA_Root" file, run the following commands:
282 </para>
283
284<screen role="nodump"><userinput>openssl x509 -in /etc/ssl/certs/Makebelieve_CA_Root.pem \
285 -text \
286 -fingerprint \
287 -setalias "Disabled Makebelieve CA Root" \
288 -addreject serverAuth \
289 -addreject emailProtection \
290 -addreject codeSigning \
291 > /etc/ssl/local/Disabled_Makebelieve_CA_Root.pem &amp;&amp;
292/usr/sbin/make-ca -r</userinput></screen>
293
294 </sect2>
295
296 <sect2 role="configuration" id="make-ca-python">
297 <title>Using make-ca with Python3</title>
298
299 <para>
300 When <application>Python3</application> was installed in LFS it included
301 the <application>pip3</application> module with vendored certificates
302 from the <application>Certifi</application> module. That was necessary,
303 but it means that whenever <command>pip3</command> is used it can reference
304 those certificates, primarily when creating a virtual environment or when
305 installing a module with all its wheel dependencies in one go.
306 </para>
307
308 <para>
309 It is generally considered that the System Administrator should be in
310 charge of which certificates are available. Now that <xref
311 linkend="make-ca"/> and <xref linkend="p11-kit"/> have been installed and
312 <application>make-ca</application> has been configured, it is possible to
313 make <command>pip3</command> use the system certificates.
314 </para>
315
316 <para>
317 The vendored certificates installed in LFS are a snapshot from when the
318 pulled-in version of <application>Certifi</application> was created. If
319 you regularly update the system certificates, the vendored version will
320 become out of date.
321 </para>
322
323 <para>
324 To use the system certificates in <application>Python3</application> you
325 should set <envar>_PIP_STANDALONE_CERT</envar> to point to them, e.g for
326 the <application>bash</application> shell:
327 </para>
328
329<screen><userinput>export _PIP_STANDALONE_CERT=/etc/pki/tls/certs/ca-bundle.crt</userinput></screen>
330
331 <warning>
332 <para>
333 If you have created virtual environments, for example when testing modules,
334 and those include the <application>Requests</application> and
335 <application>Certifi</application> modules in <filename
336 class="directory">~/.local/lib/python3.11/</filename> then those local
337 modules will be used instead of the system certificates unless you
338 remove the local modules.
339 </para>
340 </warning>
341
342 <para>
343 To use the system certificates in <application>Python3</application> with
344 the BLFS profiles add the following variable to your system or personal
345 profiles:
346 </para>
347
348<screen role="root"><userinput>mkdir -pv /etc/profile.d &amp;&amp;
349cat &gt; /etc/profile.d/pythoncerts.sh &lt;&lt; "EOF"
350<literal># Begin /etc/profile.d/pythoncerts.sh
351
352export _PIP_STANDALONE_CERT=/etc/pki/tls/certs/ca-bundle.crt
353
354# End /etc/profile.d/pythoncerts.sh</literal>
355EOF</userinput></screen>
356
357 </sect2>
358
359 <sect2 role="content">
360 <title>Contents</title>
361
362 <segmentedlist>
363 <segtitle>Installed Programs</segtitle>
364 <segtitle>Installed Directories</segtitle>
365
366 <seglistitem>
367 <seg>make-ca</seg>
368 <seg>/etc/ssl/{certs,local} and
369 /etc/pki/{nssdb,anchors,tls/{certs,java}}</seg>
370 </seglistitem>
371 </segmentedlist>
372
373 <variablelist>
374 <bridgehead renderas="sect3">Short Descriptions</bridgehead>
375 <?dbfo list-presentation="list"?>
376 <?dbhtml list-presentation="table"?>
377
378 <varlistentry id="make-ca-bin">
379 <term><command>make-ca</command></term>
380 <listitem>
381 <para>
382 is a shell script that adapts a current version of
383 <filename>certdata.txt</filename>, and prepares it for use
384 as the system trust store
385 </para>
386 <indexterm zone="make-ca make-ca">
387 <primary sortas="b-make-ca">make-ca</primary>
388 </indexterm>
389 </listitem>
390 </varlistentry>
391 </variablelist>
392
393 </sect2>
394
395</sect1>
Note: See TracBrowser for help on using the repository browser.