xref: /netbsd-src/usr.sbin/certctl/certctl.8 (revision 9a0f495ebc2aa1d572c343137847fe2d10190504)
1.\"	$NetBSD: certctl.8,v 1.3 2023/10/11 15:28:05 riastradh Exp $
2.\"
3.\" Copyright (c) 2023 The NetBSD Foundation, Inc.
4.\" All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\"    notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\"    notice, this list of conditions and the following disclaimer in the
13.\"    documentation and/or other materials provided with the distribution.
14.\"
15.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
16.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
19.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25.\" POSSIBILITY OF SUCH DAMAGE.
26.\"
27.Dd August 16, 2023
28.Dt CERTCTL 8
29.Os
30.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
31.Sh NAME
32.Nm certctl
33.Nd configure OpenSSL certificate trust anchors
34.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
35.Sh SYNOPSIS
36.Nm
37.Op Fl nv
38.Op Fl C Ar config
39.Op Fl c Ar certsdir
40.Op Fl u Ar distrustdir
41.Ar cmd
42.Op Ar args...
43.\""""""""""""""""""
44.Nm
45.Oo Ar options Oc Cm list
46.Nm
47.Oo Ar options Oc Cm rehash
48.Nm
49.Oo Ar options Oc Cm trust Ar cert
50.Nm
51.Oo Ar options Oc Cm untrust Ar cert
52.Nm
53.Oo Ar options Oc Cm untrusted
54.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
55.Sh DESCRIPTION
56The
57.Nm
58utility manages certificates used by OpenSSL-based applications as
59trust anchors for certificate validation in TLS or other purposes,
60for example by
61.Xr ftp 1
62in HTTPS.
63.Nm
64allows configuring the set of certificates and persistently excluding
65individual certificates.
66.Pp
67For trust anchors to validate TLS certificates, OpenSSL applications
68typically use a directory at
69.Pa /etc/openssl/certs
70of hashed certificates in PEM format, with names like
71.Pa "3513523f.0"
72used for lookup; see
73.Xr openssl_rehash 1 .
74.Pp
75.Nm
76scans all directories in the certificate search path specified by the
77configuration file
78.Ar config
79.Pq default: Pa /etc/openssl/certs.conf
80for files called
81.Pa *.cer ,
82.Pa *.crt ,
83or
84.Pa *.pem
85in PEM format, and keeps
86.Ar certsdir
87.Pq default: Pa /etc/openssl/certs
88populated with:
89.Bl -dash
90.It
91symlinks to the original files in the certificate search path, for
92applications that scan a directory for all files matching
93.Pa *.cer ,
94.Pa *.crt ,
95or
96.Pa *.pem ;
97.It
98hashed symlinks as in
99.Xr openssl_rehash 1 ; and
100.It
101a single-file bundle
102.Pa ca-certificates.crt
103concatenating all the certificates in PEM format.
104.El
105.Pp
106.Nm
107will exclude from
108.Ar certsdir
109any certificates that have been marked untrustworthy with
110.Nm Cm untrust ,
111which are persistently maintained in the private state directory
112.Ar distrustdir
113.Pq default: Pa /etc/openssl/untrusted .
114.Pp
115.Nm
116treats
117.Ar config
118and
119.Ar distrustdir
120as configuration, and treats
121.Ar certsdir
122strictly as a cache that can be safely deleted and rebuilt with
123.Nm Cm rehash .
124.Nm
125can also be instructed not to touch
126.Ar certsdir
127at all by putting
128.Cm manual
129in
130.Ar config .
131.\""""""""""""""""""""""""""""""""""""""
132.Ss Commands
133.Bl -tag -width Cm
134.\""""""""""""""""""
135.It Cm list
136List absolute paths to trusted certificates.
137.Nm Cm rehash
138will populate
139.Ar certsdir
140with these.
141Paths are printed one per line, encoded in
142.Xr vis 1
143format to escape any shell metacharacters.
144.\""""""""""""""""""
145.It Cm rehash
146Populate
147.Ar certsdir
148with all trusted certificates, excluding any from
149.Nm Cm untrust .
150.\""""""""""""""""""
151.It Cm trust Ar cert
152Allow
153.Ar cert
154to be included in
155.Ar certsdir
156if it is in the certificate search path, and rehash to make it
157effective immediately.
158In other words, reverse the persistent effect of
159.Nm Cm untrust Ar cert .
160.Pp
161.Ar cert
162must be the full absolute path to a certificate that has been excluded
163by
164.Nm Cm untrust Ar cert .
165.Pp
166This does not add a new certificate which is not in the search path.
167To do that, you can create a directory to hold it and put that
168directory in the search path.
169.\""""""""""""""""""
170.It Cm untrust Ar cert
171Persistently prevent
172.Ar cert
173from being included in
174.Ar certsdir ,
175and rehash to make it effective immediately.
176.Pp
177.Ar cert
178must be the full absolute path to a certificate that is in the
179certificate search path.
180.\""""""""""""""""""
181.It Cm untrusted
182List absolute paths to certificates that have been excluded by
183.Nm Cm untrust .
184.Nm Cm rehash
185will not put these in
186.Ar certsdir .
187Paths are printed one per line, encoded in
188.Xr vis 1
189format to escape any shell metacharacters.
190.\""""""""""""""""""
191.El
192.\""""""""""""""""""""""""""""""""""""""
193.Ss Configuration file
194The configuration file is a plain text file of lines separated by
195.Tn US-ASCII
196line feeds.
197.Pp
198.Pp
199The first line must be:
200.Dl netbsd-certctl 20230816
201.Pp
202Lines with only whitespace, or whitespace followed by the comment
203character
204.Ql #
205are ignored.
206Each line has a directive and arguments separated by whitespace, and
207may be extended by
208.Ql \e
209to continuation lines.
210.Bl -tag -width Cm
211.\""""""""""""""""""
212.It Cm path Ar dir
213Add
214.Ar dir
215to the certificate search path.
216.Ar dir
217must be an absolute pathname,
218.Xr vis 3 Ns -encoded
219if it has any characters outside the class
220.Ql "a-zA-Z0-9,.:=/+-" .
221.Pp
222All certificates must have unique base names across all directories
223in the certificate search path.
224.\""""""""""""""""""
225.It Cm manual
226Manual override.
227If specified,
228.Nm
229will
230.Em not
231modify
232.Ar certsdir ,
233but may still check consistency of the configuration when run, and
234.Nm Cm untrust
235and
236.Nm Cm trust
237will still update
238.Ar distrustdir .
239.\""""""""""""""""""
240.El
241.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
242.Sh FILES
243.Bl -tag -width Pa
244.It Pa /etc/openssl/certs
245Default directory of hashed TLS CA certificates.
246.It Pa /etc/openssl/certs/ca-certificates.crt
247Default single-file TLS CA certificate bundle.
248.It Pa /etc/openssl/certs.conf
249Default configuration file for TLS CA certificates.
250.It Pa /etc/openssl/untrusted
251Default
252.Ar distrustdir
253directory of excluded TLS CA certificates.
254.It Pa /usr/share/certs/mozilla/all
255All root CA certificates published by Mozilla, including untrustworthy
256certificates.
257.It Pa /usr/share/certs/mozilla/code
258All root CA certificates published by Mozilla for use in code-signing.
259.It Pa /usr/share/certs/mozilla/email
260All root CA certificates published by Mozilla for use in email
261authentication.
262.It Pa /usr/share/certs/mozilla/server
263All root CA certificates published by Mozilla for use in TLS server
264authentication.
265.El
266.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
267.Sh EXAMPLES
268Example configuration file
269.Pq Pa /etc/openssl/certs.conf :
270.Bd -literal -offset indent
271netbsd-certctl 20230816
272
273# Blank lines and comments are ignored.
274# Comments begin with a `#' sign.
275
276# Gather certificates from files called *.cer, *.crt, and *.pem
277# under these directories.
278path /usr/share/certs/mozilla/server
279path /usr/pkg/share/chromium-cacerts
280path /etc/openssl/certs.local
281
282# If the next line is uncommented, certctl(8) will decline to
283# touch /etc/openssl/certs.
284#manual
285.Ed
286.Pp
287Exclude a certificate:
288.Bd -literal -offset indent
289$ certctl untrust /usr/share/certs/mozilla/server/GTS_Root_R1.pem
290.Ed
291.Pp
292There is no need to run
293.Nm Cm rehash
294explicitly after
295.Nm Cm untrust ,
296but if you do, the setting will persist.
297.Pp
298Rebuild the hashed certificate cache at
299.Pa /etc/myapplication/certs
300from
301.Pa /etc/myapplication/certs.conf
302and
303.Pa /etc/myapplication/untrusted :
304.Bd -literal -offset indent
305$ certctl -c /etc/myapplication/certs \e
306        -C /etc/myapplication/certs.conf \e
307        -u /etc/myapplication/untrusted
308.Ed
309.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
310.Sh DIAGNOSTICS
311.Ex -std
312.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
313.Sh COMPATIBILITY
314The
315.Nm
316utility is mostly compatible with a utility of the same name in
317.Fx .
318Differences:
319.Bl -enum
320.\""""""""""""""""""
321.It
322.Fx Nm
323supports destdir/metalog handling;
324.Nx Nm
325does not.
326.\""""""""""""""""""
327.It
328.Fx Nm
329treats
330.Pa /etc/ssl/certs
331and
332.Pa /etc/ssl/untrusted
333both as configuration
334.Em and
335as caches;
336.Nx Nm
337treats
338.Pa /etc/openssl/certs.conf
339and
340.Pa /etc/openssl/untrusted
341as configuration, and treats
342.Pa /etc/openssl/certs
343strictly as a cache.
344.Fx Nm
345will forget any
346.Nm Cm untrust
347settings on
348.Nm Cm rehash ,
349but
350.Nx Nm
351will remember them.
352.\""""""""""""""""""
353.It
354.Fx Nm
355takes configuration through environment variables;
356.Nx Nm
357takes configuration through a file and command-line arguments.
358.El
359.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
360.Sh SEE ALSO
361.Xr openssl 1 ,
362.Xr openssl_rehash 1
363.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
364.Sh HISTORY
365.Nm
366first appeared in
367.Nx 10.0 .
368A utility of the same name previously appeared in
369.Fx 12.2 .
370