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