Imported Upstream version 2.4.3
[platform/upstream/gpg2.git] / doc / dirmngr.texi
1 @c Copyright (C) 2002 Klar"alvdalens Datakonsult AB
2 @c Copyright (C) 2004, 2005, 2006, 2007 g10 Code GmbH
3 @c This is part of the GnuPG manual.
4 @c For copying conditions, see the file gnupg.texi.
5
6 @include defs.inc
7
8 @node Invoking DIRMNGR
9 @chapter Invoking DIRMNGR
10 @cindex DIRMNGR command options
11 @cindex command options
12 @cindex options, DIRMNGR command
13
14 @manpage dirmngr.8
15 @ifset manverb
16 .B dirmngr
17 \- GnuPG's network access daemon
18 @end ifset
19
20 @mansect synopsis
21 @ifset manverb
22 .B  dirmngr
23 .RI [ options ]
24 .I command
25 .RI [ args ]
26 @end ifset
27
28 @mansect description
29 Since version 2.1 of GnuPG, @command{dirmngr} takes care of accessing
30 the OpenPGP keyservers.  As with previous versions it is also used as
31 a server for managing and downloading certificate revocation lists
32 (CRLs) for X.509 certificates, downloading X.509 certificates, and
33 providing access to OCSP providers.  Dirmngr is invoked internally by
34 @command{gpg}, @command{gpgsm}, or via the @command{gpg-connect-agent}
35 tool.
36
37 @manpause
38 @noindent
39 @xref{Option Index},for an index to @command{DIRMNGR}'s commands and
40 options.
41 @mancont
42
43 @menu
44 * Dirmngr Commands::      List of all commands.
45 * Dirmngr Options::       List of all options.
46 * Dirmngr Configuration:: Configuration files.
47 * Dirmngr Signals::       Use of signals.
48 * Dirmngr Examples::      Some usage examples.
49 * Dirmngr Protocol::      The protocol dirmngr uses.
50 @end menu
51
52
53 @node Dirmngr Commands
54 @section Commands
55 @mansect commands
56
57 Commands are not distinguished from options except for the fact that
58 only one command is allowed.
59
60 @table @gnupgtabopt
61 @item --version
62 @opindex version
63 Print the program version and licensing information.  Note that you cannot
64 abbreviate this command.
65
66 @item --help, -h
67 @opindex help
68 Print a usage message summarizing the most useful command-line options.
69 Note that you cannot abbreviate this command.
70
71 @item --dump-options
72 @opindex dump-options
73 Print a list of all available options and commands.  Note that you cannot
74 abbreviate this command.
75
76 @item --server
77 @opindex server
78 Run in server mode and wait for commands on the @code{stdin}.  The
79 default mode is to create a socket and listen for commands there.
80 This is only used for testing.
81
82 @item --daemon
83 @opindex daemon
84 Run in background daemon mode and listen for commands on a socket.
85 This is the way @command{dirmngr} is started on demand by the other
86 GnuPG components.  To force starting @command{dirmngr} it is in
87 general best to use @code{gpgconf --launch dirmngr}.
88
89 @item --supervised
90 @opindex supervised
91 Run in the foreground, sending logs to stderr, and listening on file
92 descriptor 3, which must already be bound to a listening socket.  This
93 option is deprecated and not supported on Windows.
94
95 @item --list-crls
96 @opindex list-crls
97 List the contents of the CRL cache on @code{stdout}. This is probably
98 only useful for debugging purposes.
99
100 @item --load-crl @var{file}
101 @opindex load-crl
102 This command requires a filename as additional argument, and it will
103 make Dirmngr try to import the CRL in @var{file} into it's cache.
104 Note, that this is only possible if Dirmngr is able to retrieve the
105 CA's certificate directly by its own means.  In general it is better
106 to use @code{gpgsm}'s @code{--call-dirmngr loadcrl filename} command
107 so that @code{gpgsm} can help dirmngr.
108
109 @item --fetch-crl @var{url}
110 @opindex fetch-crl
111 This command requires an URL as additional argument, and it will make
112 dirmngr try to retrieve and import the CRL from that @var{url} into
113 it's cache.  This is mainly useful for debugging purposes.  The
114 @command{dirmngr-client} provides the same feature for a running dirmngr.
115
116 @item --shutdown
117 @opindex shutdown
118 This commands shuts down an running instance of Dirmngr.  This command
119 has currently no effect.
120
121 @item --flush
122 @opindex flush
123 This command removes all CRLs from Dirmngr's cache.  Client requests
124 will thus trigger reading of fresh CRLs.
125
126 @end table
127
128
129 @mansect options
130 @node Dirmngr Options
131 @section Option Summary
132
133 Note that all long options with the exception of @option{--options}
134 and @option{--homedir} may also be given in the configuration file
135 after stripping off the two leading dashes.
136
137 @table @gnupgtabopt
138
139 @item --options @var{file}
140 @opindex options
141 Reads configuration from @var{file} instead of from the default
142 per-user configuration file.  The default configuration file is named
143 @file{dirmngr.conf} and expected in the home directory.
144
145 @item --homedir @var{dir}
146 @opindex options
147 Set the name of the home directory to @var{dir}.  This option is only
148 effective when used on the command line.  The default is
149 the directory named @file{.gnupg} directly below the home directory
150 of the user unless the environment variable @code{GNUPGHOME} has been set
151 in which case its value will be used.  Many kinds of data are stored within
152 this directory.
153
154
155 @item -v
156 @item --verbose
157 @opindex v
158 @opindex verbose
159 Outputs additional information while running.
160 You can increase the verbosity by giving several
161 verbose commands to @sc{dirmngr}, such as @option{-vv}.
162
163
164 @item --log-file @var{file}
165 @opindex log-file
166 Append all logging output to @var{file}.  This is very helpful in
167 seeing what the agent actually does.  Use @file{socket://} to log to
168 socket.
169
170 @item --compatibility-flags @var{flags}
171 @opindex compatibility-flags
172 Set compatibility flags to work around certain problems or to emulate
173 bugs.  The @var{flags} are given as a comma separated list of flag
174 names and are OR-ed together.  The special flag "none" clears the list
175 and allows to start over with an empty list.  To get a list of
176 available flags the sole word "help" can be used.
177
178 @item --debug-level @var{level}
179 @opindex debug-level
180 Select the debug level for investigating problems.  @var{level} may be a
181 numeric value or by a keyword:
182
183 @table @code
184 @item none
185 No debugging at all.  A value of less than 1 may be used instead of
186 the keyword.
187 @item basic
188 Some basic debug messages.  A value between 1 and 2 may be used
189 instead of the keyword.
190 @item advanced
191 More verbose debug messages.  A value between 3 and 5 may be used
192 instead of the keyword.
193 @item expert
194 Even more detailed messages.  A value between 6 and 8 may be used
195 instead of the keyword.
196 @item guru
197 All of the debug messages you can get. A value greater than 8 may be
198 used instead of the keyword.  The creation of hash tracing files is
199 only enabled if the keyword is used.
200 @end table
201
202 How these messages are mapped to the actual debugging flags is not
203 specified and may change with newer releases of this program. They are
204 however carefully selected to best aid in debugging.
205
206 @item --debug @var{flags}
207 @opindex debug
208 Set debug flags.  All flags are or-ed and @var{flags} may be given in
209 C syntax (e.g. 0x0042) or as a comma separated list of flag names.  To
210 get a list of all supported flags the single word "help" can be used.
211 This option is only useful for debugging and the behavior may change
212 at any time without notice.
213
214 @item --debug-all
215 @opindex debug-all
216 Same as @code{--debug=0xffffffff}
217
218 @item --tls-debug @var{level}
219 @opindex tls-debug
220 Enable debugging of the TLS layer at @var{level}.  The details of the
221 debug level depend on the used TLS library and are not set in stone.
222
223 @item --debug-wait @var{n}
224 @opindex debug-wait
225 When running in server mode, wait @var{n} seconds before entering the
226 actual processing loop and print the pid.  This gives time to attach a
227 debugger.
228
229 @item --disable-check-own-socket
230 @opindex disable-check-own-socket
231 On some platforms @command{dirmngr} is able to detect the removal of
232 its socket file and shutdown itself.  This option disable this
233 self-test for debugging purposes.
234
235 @item -s
236 @itemx --sh
237 @itemx -c
238 @itemx --csh
239 @opindex s
240 @opindex sh
241 @opindex c
242 @opindex csh
243 Format the info output in daemon mode for use with the standard Bourne
244 shell respective the C-shell. The default is to guess it based on the
245 environment variable @code{SHELL} which is in almost all cases
246 sufficient.
247
248 @item --force
249 @opindex force
250 Enabling this option forces loading of expired CRLs; this is only
251 useful for debugging.
252
253 @item --use-tor
254 @itemx --no-use-tor
255 @opindex use-tor
256 @opindex no-use-tor
257 The option @option{--use-tor} switches Dirmngr and thus GnuPG into
258 ``Tor mode'' to route all network access via Tor (an anonymity
259 network).  Certain other features are disabled in this mode.  The
260 effect of @option{--use-tor} cannot be overridden by any other command
261 or even by reloading dirmngr.  The use of @option{--no-use-tor}
262 disables the use of Tor.  The default is to use Tor if it is available
263 on startup or after reloading dirmngr.  The test on the availability of
264 Tor is done by trying to connect to a SOCKS proxy at either port 9050
265 or 9150; if another type of proxy is listening on one of these ports,
266 you should use @option{--no-use-tor}.
267
268 @item --standard-resolver
269 @opindex standard-resolver
270 This option forces the use of the system's standard DNS resolver code.
271 This is mainly used for debugging.  Note that on Windows a standard
272 resolver is not used and all DNS access will return the error ``Not
273 Implemented'' if this option is used.  Using this together with enabled
274 Tor mode returns the error ``Not Enabled''.
275
276 @item --recursive-resolver
277 @opindex recursive-resolver
278 When possible use a recursive resolver instead of a stub resolver.
279
280 @item --resolver-timeout @var{n}
281 @opindex resolver-timeout
282 Set the timeout for the DNS resolver to N seconds.  The default are 30
283 seconds.
284
285 @item --connect-timeout @var{n}
286 @item --connect-quick-timeout @var{n}
287 @opindex connect-timeout
288 @opindex connect-quick-timeout
289 Set the timeout for HTTP and generic TCP connection attempts to N
290 seconds.  The value set with the quick variant is used when the
291 --quick option has been given to certain Assuan commands.  The quick
292 value is capped at the value of the regular connect timeout.  The
293 default values are 15 and 2 seconds.  Note that the timeout values are
294 for each connection attempt; the connection code will attempt to
295 connect all addresses listed for a server.
296
297 @item --listen-backlog @var{n}
298 @opindex listen-backlog
299 Set the size of the queue for pending connections.  The default is 64.
300
301 @item --allow-version-check
302 @opindex allow-version-check
303 Allow Dirmngr to connect to @code{https://versions.gnupg.org} to get
304 the list of current software versions.  If this option is enabled
305 the list is retrieved in case the local
306 copy does not exist or is older than 5 to 7 days.  See the option
307 @option{--query-swdb} of the command @command{gpgconf} for more
308 details.  Note, that regardless of this option a version check can
309 always be triggered using this command:
310
311 @example
312        gpg-connect-agent --dirmngr 'loadswdb --force' /bye
313 @end example
314
315
316 @item --keyserver @var{name}
317 @opindex keyserver
318 Use @var{name} as your keyserver.  This is the server that @command{gpg}
319 communicates with to receive keys, send keys, and search for
320 keys.  The format of the @var{name} is a URI:
321 `scheme:[//]keyservername[:port]' The scheme is the type of keyserver:
322 "hkp" for the HTTP (or compatible) keyservers or "ldap" for the LDAP
323 keyservers. Note that your particular installation of GnuPG may have
324 other keyserver types available as well. Keyserver schemes are
325 case-insensitive. After the keyserver name, optional keyserver
326 configuration options may be provided.  These are the same as the
327 @option{--keyserver-options} of @command{gpg}, but apply only to this
328 particular keyserver.
329
330 Some keyservers synchronize with each other, so there is not always a
331 need to send keys to more than one server. Some keyservers use round
332 robin DNS to give a different keyserver each time you use it.
333
334 If exactly two keyservers are configured and only one is a Tor hidden
335 service (.onion), Dirmngr selects the keyserver to use depending on
336 whether Tor is locally running or not.  The check for a running Tor is
337 done for each new connection.
338
339 If no keyserver is explicitly configured, dirmngr will use the
340 built-in default of @code{https://keyserver.ubuntu.com}.
341
342 Windows users with a keyserver running on their Active Directory
343 may use the short form @code{ldap:///} for @var{name} to access this directory.
344
345 For accessing anonymous LDAP keyservers @var{name} is in general just
346 a @code{ldaps://ldap.example.com}.  A BaseDN parameter should never be
347 specified.  If authentication is required things are more complicated
348 and two methods are available:
349
350 The modern method (since version 2.2.28) is to use the very same syntax
351 as used with the option @option{--ldapserver}.  Please see over
352 there for details; here is an example:
353
354 @example
355        keyserver ldap:ldap.example.com::uid=USERNAME,ou=GnuPG Users,
356        dc=example,dc=com:PASSWORD::starttls
357 @end example
358
359        The other method is to use a full URL for @var{name}; for example:
360
361 @example
362        keyserver ldaps://ldap.example.com/????bindname=uid=USERNAME
363        %2Cou=GnuPG%20Users%2Cdc=example%2Cdc=com,password=PASSWORD
364 @end example
365
366        Put this all on one line without any spaces and keep the '%2C'
367        as given.  Replace USERNAME, PASSWORD, and the 'dc' parts
368        according to the instructions received from your LDAP
369        administrator.  Note that only simple authentication
370        (i.e. cleartext passwords) is supported and thus using ldaps is
371        strongly suggested (since 2.2.28 "ldaps" defaults to port 389
372        and uses STARTTLS).  On Windows authentication via AD can be
373        requested by adding @code{gpgNtds=1} after the fourth question
374        mark instead of the bindname and password parameter.
375
376
377
378 @item --nameserver @var{ipaddr}
379 @opindex nameserver
380 In ``Tor mode'' Dirmngr uses a public resolver via Tor to resolve DNS
381 names.  If the default public resolver, which is @code{8.8.8.8}, shall
382 not be used a different one can be given using this option.  Note that
383 a numerical IP address must be given (IPv6 or IPv4) and that no error
384 checking is done for @var{ipaddr}.
385
386 @item --disable-ipv4
387 @item --disable-ipv6
388 @opindex disable-ipv4
389 @opindex disable-ipv6
390 Disable the use of all IPv4 or IPv6 addresses.
391
392 @item --disable-ldap
393 @opindex disable-ldap
394 Entirely disables the use of LDAP.
395
396 @item --disable-http
397 @opindex disable-http
398 Entirely disables the use of HTTP.
399
400 @item --ignore-http-dp
401 @opindex ignore-http-dp
402 When looking for the location of a CRL, the to be tested certificate
403 usually contains so called @dfn{CRL Distribution Point} (DP) entries
404 which are URLs describing the way to access the CRL.  The first found DP
405 entry is used.  With this option all entries using the @acronym{HTTP}
406 scheme are ignored when looking for a suitable DP.
407
408 @item --ignore-ldap-dp
409 @opindex ignore-ldap-dp
410 This is similar to @option{--ignore-http-dp} but ignores entries using
411 the @acronym{LDAP} scheme.  Both options may be combined resulting in
412 ignoring DPs entirely.
413
414 @item --ignore-ocsp-service-url
415 @opindex ignore-ocsp-service-url
416 Ignore all OCSP URLs contained in the certificate.  The effect is to
417 force the use of the default responder.
418
419 @item --honor-http-proxy
420 @opindex honor-http-proxy
421 If the environment variable @env{http_proxy} has been set, use its
422 value to access HTTP servers.
423
424 @item --http-proxy @var{host}[:@var{port}]
425 @opindex http-proxy
426 @efindex http_proxy
427 Use @var{host} and @var{port} to access HTTP servers.  The use of this
428 option overrides the environment variable @env{http_proxy} regardless
429 whether @option{--honor-http-proxy} has been set.
430
431
432 @item --ldap-proxy @var{host}[:@var{port}]
433 @opindex ldap-proxy
434 Use @var{host} and @var{port} to connect to LDAP servers.  If @var{port}
435 is omitted, port 389 (standard LDAP port) is used.  This overrides any
436 specified host and port part in a LDAP URL and will also be used if host
437 and port have been omitted from the URL.
438
439 @item --only-ldap-proxy
440 @opindex only-ldap-proxy
441 Never use anything else but the LDAP "proxy" as configured with
442 @option{--ldap-proxy}.  Usually @command{dirmngr} tries to use other
443 configured LDAP server if the connection using the "proxy" failed.
444
445
446 @item --ldapserverlist-file @var{file}
447 @opindex ldapserverlist-file
448 Read the list of LDAP servers to consult for CRLs and X.509 certificates from
449 file instead of the default per-user ldap server list file. The default
450 value for @var{file} is @file{dirmngr_ldapservers.conf}.
451
452 This server list file contains one LDAP server per line in the format
453
454 @sc{hostname:port:username:password:base_dn:flags}
455
456 Lines starting with a  @samp{#} are comments.
457
458 Note that as usual all strings entered are expected to be UTF-8 encoded.
459 Obviously this will lead to problems if the password has originally been
460 encoded as Latin-1.  There is no other solution here than to put such a
461 password in the binary encoding into the file (i.e. non-ascii characters
462 won't show up readable).@footnote{The @command{gpgconf} tool might be
463 helpful for frontends as it enables editing this configuration file using
464 percent-escaped strings.}
465
466
467 @item --ldapserver @var{spec}
468 @opindex ldapserver
469 This is an alternative way to specify LDAP servers for CRL and X.509
470 certificate retrieval.  If this option is used the servers configured
471 in @file{dirmngr_ldapservers.conf} (or the file given by
472 @option{--ldapserverlist-file}) are cleared.  Note that
473 @file{dirmngr_ldapservers.conf} is not read again by a reload
474 signal. However, @option{--ldapserver} options are read again.
475
476 @var{spec} is either a proper LDAP URL or a colon delimited list of
477 the form
478
479 @sc{hostname:port:username:password:base_dn:flags:}
480
481 with an optional prefix of @code{ldap:} (but without the two slashes
482 which would turn this into a proper LDAP URL).  @sc{flags} is a list
483 of one or more comma delimited keywords:
484 @table @code
485 @item plain
486 The default: Do not use a TLS secured connection at all; the default
487 port is 389.
488 @item starttls
489 Use STARTTLS to secure the connection; the default port is 389.
490 @item ldaptls
491 Tunnel LDAP through a TLS connection; the default port is 636.
492 @item ntds
493 On Windows authenticate the LDAP connection using the Active Directory
494 with the current user.
495 @item areconly
496 On Windows use only the A or AAAA record when resolving the LDAP
497 server name.
498 @end table
499
500 Note that in an URL style specification the scheme @code{ldaps://}
501 refers to STARTTLS and _not_ to LDAP-over-TLS.
502
503
504 @item --ldaptimeout @var{secs}
505 @opindex ldaptimeout
506 Specify the number of seconds to wait for an LDAP query before timing
507 out.  The default are 15 seconds.  0 will never timeout.
508
509
510 @item --add-servers
511 @opindex add-servers
512 This option makes dirmngr add any servers it discovers when validating
513 certificates against CRLs to the internal list of servers to consult for
514 certificates and CRLs.  This option should in general not be used.
515
516 This option might be useful when trying to validate a certificate that
517 has a CRL distribution point that points to a server that is not
518 already listed in the ldapserverlist.  Dirmngr will always go to this
519 server and try to download the CRL, but chances are high that the
520 certificate used to sign the CRL is located on the same server. So if
521 dirmngr doesn't add that new server to list, it will often not be able
522 to verify the signature of the CRL unless the @code{--add-servers}
523 option is used.
524
525 Caveat emptor: Using this option may enable denial-of-service attacks
526 and leak search requests to unknown third parties.  This is because
527 arbitrary servers are added to the internal list of LDAP servers which
528 in turn is used for all unspecific LDAP queries as well as a fallback
529 for queries which did not return a result.
530
531
532 @item --allow-ocsp
533 @opindex allow-ocsp
534 This option enables OCSP support if requested by the client.
535
536 OCSP requests are rejected by default because they may violate the
537 privacy of the user; for example it is possible to track the time when
538 a user is reading a mail.
539
540
541 @item --ocsp-responder @var{url}
542 @opindex ocsp-responder
543 Use @var{url} as the default OCSP Responder if the certificate does
544 not contain information about an assigned responder.  Note, that
545 @code{--ocsp-signer} must also be set to a valid certificate.
546
547 @item --ocsp-signer @var{fpr}|@var{file}
548 @opindex ocsp-signer
549 Use the certificate with the fingerprint @var{fpr} to check the
550 responses of the default OCSP Responder.  Alternatively a filename can be
551 given in which case the response is expected to be signed by one of the
552 certificates described in that file.  Any argument which contains a
553 slash, dot or tilde is considered a filename.  Usual filename expansion
554 takes place: A tilde at the start followed by a slash is replaced by the
555 content of @env{HOME}, no slash at start describes a relative filename
556 which will be searched at the home directory.  To make sure that the
557 @var{file} is searched in the home directory, either prepend the name
558 with "./" or use a name which contains a dot.
559
560 If a response has been signed by a certificate described by these
561 fingerprints no further check upon the validity of this certificate is
562 done.
563
564 The format of the @var{FILE} is a list of SHA-1 fingerprint, one per
565 line with optional colons between the bytes.  Empty lines and lines
566 prefix with a hash mark are ignored.
567
568
569 @item --ocsp-max-clock-skew @var{n}
570 @opindex ocsp-max-clock-skew
571 The number of seconds a skew between the OCSP responder and them local
572 clock is accepted.  Default is 600 (10 minutes).
573
574 @item --ocsp-max-period @var{n}
575 @opindex ocsp-max-period
576 Seconds a response is at maximum considered valid after the time given
577 in the thisUpdate field.  Default is 7776000 (90 days).
578
579 @item --ocsp-current-period @var{n}
580 @opindex ocsp-current-period
581 The number of seconds an OCSP response is considered valid after the
582 time given in the NEXT_UPDATE datum.  Default is 10800 (3 hours).
583
584
585 @item --max-replies @var{n}
586 @opindex max-replies
587 Do not return more that @var{n} items in one query.  The default is
588 10.
589
590 @item --ignore-cert-extension @var{oid}
591 @opindex ignore-cert-extension
592 Add @var{oid} to the list of ignored certificate extensions.  The
593 @var{oid} is expected to be in dotted decimal form, like
594 @code{2.5.29.3}.  This option may be used more than once.  Critical
595 flagged certificate extensions matching one of the OIDs in the list
596 are treated as if they are actually handled and thus the certificate
597 won't be rejected due to an unknown critical extension.  Use this
598 option with care because extensions are usually flagged as critical
599 for a reason.
600
601 @item --ignore-crl-extension @var{oid}
602 @opindex ignore-crl-extension
603 Add @var{oid} to the list of ignored CRL extensions.  The @var{oid} is
604 expected to be in dotted decimal form.  Critical flagged CRL
605 extensions matching one of the OIDs in the list are treated as if they
606 are actually handled and thus the certificate won't be rejected due to
607 an unknown critical extension.  Use this option with care because
608 extensions are usually flagged as critical for a reason.
609
610 @item --ignore-cert @var{fpr}|@var{file}
611 @opindex ignore-cert
612 Entirely ignore certificates with the fingerprint @var{fpr}.  As an
613 alternative to the fingerprint a filename can be given in which case
614 all certificates described in that file are ignored.  Any argument
615 which contains a slash, dot or tilde is considered a filename.  Usual
616 filename expansion takes place: A tilde at the start followed by a
617 slash is replaced by the content of @env{HOME}, no slash at start
618 describes a relative filename which will be searched at the home
619 directory.  To make sure that the @var{file} is searched in the home
620 directory, either prepend the name with "./" or use a name which
621 contains a dot.  The format of such a file is a list of SHA-1
622 fingerprint, one per line with optional colons between the bytes.
623 Empty lines and lines prefixed with a hash mark are ignored.
624
625 This option is useful as a quick workaround to exclude certain
626 certificates from the system store.
627
628
629 @item --hkp-cacert @var{file}
630 Use the root certificates in @var{file} for verification of the TLS
631 certificates used with @code{hkps} (keyserver access over TLS).  If
632 the file is in PEM format a suffix of @code{.pem} is expected for
633 @var{file}.  This option may be given multiple times to add more
634 root certificates.  Tilde expansion is supported.
635
636 If no @code{hkp-cacert} directive is present, dirmngr will use the
637 system CAs.
638
639 @end table
640
641
642 @c
643 @c Dirmngr Configuration
644 @c
645 @mansect files
646 @node Dirmngr Configuration
647 @section Configuration
648
649 Dirmngr makes use of several directories when running in daemon mode:
650 There are a few configuration files to control the operation of
651 dirmngr.  By default they may all be found in the current home
652 directory (@pxref{option --homedir}).
653
654 @table @file
655
656 @item dirmngr.conf
657 @efindex dirmngr.conf
658 This is the standard configuration file read by @command{dirmngr} on
659 startup.  It may contain any valid long option; the leading two dashes
660 may not be entered and the option may not be abbreviated.  This file
661 is also read after a @code{SIGHUP} however not all options will
662 actually have an effect.  This default name may be changed on the
663 command line (@pxref{option --options}).  You should backup this file.
664
665 @item /etc/gnupg/trusted-certs
666 This directory should be filled with certificates of Root CAs you
667 are trusting in checking the CRLs and signing OCSP Responses.
668
669 Usually these are the same certificates you use with the applications
670 making use of dirmngr.  It is expected that each of these certificate
671 files contain exactly one @acronym{DER} encoded certificate in a file
672 with the suffix @file{.crt} or @file{.der}.  @command{dirmngr} reads
673 those certificates on startup and when given a SIGHUP.  Certificates
674 which are not readable or do not make up a proper X.509 certificate
675 are ignored; see the log file for details.
676
677 Applications using dirmngr (e.g. gpgsm) can request these
678 certificates to complete a trust chain in the same way as with the
679 extra-certs directory (see below).
680
681 Note that for OCSP responses the certificate specified using the option
682 @option{--ocsp-signer} is always considered valid to sign OCSP requests.
683
684 @item /etc/gnupg/extra-certs
685 This directory may contain extra certificates which are preloaded
686 into the internal cache on startup. Applications using dirmngr (e.g. gpgsm)
687 can request cached certificates to complete a trust chain.
688 This is convenient in cases you have a couple intermediate CA certificates
689 or certificates usually used to sign OCSP responses.
690 These certificates are first tried before going
691 out to the net to look for them.  These certificates must also be
692 @acronym{DER} encoded and suffixed with @file{.crt} or @file{.der}.
693
694 @item ~/.gnupg/crls.d
695 This directory is used to store cached CRLs.  The @file{crls.d}
696 part will be created by dirmngr if it does not exists but you need to
697 make sure that the upper directory exists.
698
699 @end table
700
701 Several options control the use of trusted certificates for TLS and
702 CRLs.  Here is an Overview on the use and origin of those Root CA
703 certificates:
704 @table @asis
705
706 @item System
707
708 These System root certificates are used by:  FIXME
709
710 The origin of the system provided certificates depends on the
711 platform.  On Windows all certificates from the Windows System Stores
712 @code{ROOT} and @code{CA} are used.
713
714 On other platforms the certificates are read from the first file found
715 form this list: @file{/etc/ssl/ca-bundle.pem},
716 @file{/etc/ssl/certs/ca-certificates.crt},
717 @file{/etc/pki/tls/cert.pem},
718 @file{/usr/local/share/certs/ca-root-nss.crt},
719 @file{/etc/ssl/cert.pem}.
720
721 @item GnuPG
722
723 The GnuPG specific certificates stored in the directory
724 @file{/etc/gnupg/trusted-certs} are only used to validate CRLs.
725
726 @c Note that dirmngr's VALIDATE command also uses them but that
727 @c command is anyway only intended for debugging.
728
729 @item OpenPGP keyserver
730
731 For accessing the OpenPGP keyservers the only certificates used are
732 those set with the configuration option @option{hkp-cacert}.
733
734 @item OpenPGP keyserver pool
735
736 This is usually only one certificate read from the file
737 @file{@value{DATADIR}/gnupg/sks-keyservers.netCA.pem}.  If this
738 certificate exists it is used to access the special keyservers
739 @code{hkps.pool.sks-keyservers.net} (or @file{hkps://keys.gnupg.net}).
740
741 @end table
742
743 Please note that @command{gpgsm} accepts Root CA certificates for its
744 own purposes only if they are listed in its file @file{trustlist.txt}.
745 @command{dirmngr} does not make use of this list - except FIXME.
746
747
748 @mansect notes
749
750 To be able to see diagnostics it is often useful to put at least the
751 following lines into the configuration file
752 @file{~/gnupg/dirmngr.conf}:
753
754 @example
755 log-file ~/dirmngr.log
756 verbose
757 @end example
758
759 You may want to check the log file to see whether all desired root CA
760 certificates are correctly loaded.
761
762 To be able to perform OCSP requests you probably want to add the line:
763
764 @example
765 allow-ocsp
766 @end example
767
768 To make sure that new options are read or that after the installation
769 of a new GnuPG versions the right dirmngr version is running, you
770 should kill an existing dirmngr so that a new instance is started as
771 needed by the other components:
772
773 @example
774 gpgconf --kill dirmngr
775 @end example
776
777 Direct interfaction with the dirmngr is possible by using the command
778
779 @example
780 gpg-connect-agent --dirmngr
781 @end example
782
783 Enter @code{HELP} at the prompt to see a list of commands and enter
784 @code{HELP} followed by a command name to get help on that command.
785
786
787
788 @c
789 @c Dirmngr Signals
790 @c
791 @mansect signals
792 @node Dirmngr Signals
793 @section Use of signals
794
795 A running @command{dirmngr} may be controlled by signals, i.e. using
796 the @command{kill} command to send a signal to the process.
797
798 Here is a list of supported signals:
799
800 @table @gnupgtabopt
801
802 @item SIGHUP
803 @cpindex SIGHUP
804 This signal flushes all internally cached CRLs as well as any cached
805 certificates.  Then the certificate cache is reinitialized as on
806 startup.  Options are re-read from the configuration file.  Instead of
807 sending this signal it is better to use
808 @example
809 gpgconf --reload dirmngr
810 @end example
811
812 @item SIGTERM
813 @cpindex SIGTERM
814 Shuts down the process but waits until all current requests are
815 fulfilled.  If the process has received 3 of these signals and requests
816 are still pending, a shutdown is forced.  You may also use
817 @example
818 gpgconf --kill dirmngr
819 @end example
820 instead of this signal
821
822 @item SIGINT
823 @cpindex SIGINT
824 Shuts down the process immediately.
825
826
827 @item SIGUSR1
828 @cpindex SIGUSR1
829 This prints some caching statistics to the log file.
830
831 @end table
832
833
834
835 @c
836 @c  Examples
837 @c
838 @mansect examples
839 @node Dirmngr Examples
840 @section Examples
841
842 Here is an example on how to show dirmngr's internal table of OpenPGP
843 keyserver addresses.  The output is intended for debugging purposes
844 and not part of a defined API.
845
846 @example
847   gpg-connect-agent --dirmngr 'keyserver --hosttable' /bye
848 @end example
849
850 To inhibit the use of a particular host you have noticed in one of the
851 keyserver pools, you may use
852
853 @example
854  gpg-connect-agent --dirmngr 'keyserver --dead pgpkeys.bnd.de' /bye
855 @end example
856
857 The description of the @code{keyserver} command can be printed using
858
859 @example
860  gpg-connect-agent --dirmngr 'help keyserver' /bye
861 @end example
862
863
864
865 @c
866 @c  Assuan Protocol
867 @c
868 @manpause
869 @node Dirmngr Protocol
870 @section Dirmngr's Assuan Protocol
871
872 Assuan is the IPC protocol used to access dirmngr.  This is a
873 description of the commands implemented by dirmngr.
874
875 @menu
876 * Dirmngr LOOKUP::      Look up a certificate via LDAP
877 * Dirmngr ISVALID::     Validate a certificate using a CRL or OCSP.
878 * Dirmngr CHECKCRL::    Validate a certificate using a CRL.
879 * Dirmngr CHECKOCSP::   Validate a certificate using OCSP.
880 * Dirmngr CACHECERT::   Put a certificate into the internal cache.
881 * Dirmngr VALIDATE::    Validate a certificate for debugging.
882 @end menu
883
884 @node Dirmngr LOOKUP
885 @subsection Return the certificate(s) found
886
887 Lookup certificate.  To allow multiple patterns (which are ORed)
888 quoting is required: Spaces are to be translated into "+" or into
889 "%20"; obviously this requires that the usual escape quoting rules
890 are applied.  The server responds with:
891
892 @example
893   S: D <DER encoded certificate>
894   S: END
895   S: D <second DER encoded certificate>
896   S: END
897   S: OK
898 @end example
899
900 In this example 2 certificates are returned.  The server may return
901 any number of certificates; OK will also be returned when no
902 certificates were found.  The dirmngr might return a status line
903
904 @example
905   S: S TRUNCATED <n>
906 @end example
907
908
909 To indicate that the output was truncated to N items due to a
910 limitation of the server or by an arbitrary set limit.
911
912 The option @option{--url} may be used if instead of a search pattern a
913 complete URL to the certificate is known:
914
915 @example
916   C: LOOKUP --url CN%3DWerner%20Koch,o%3DIntevation%20GmbH,c%3DDE?userCertificate
917 @end example
918
919 If the option @option{--cache-only} is given, no external lookup is done
920 so that only certificates from the cache are returned.
921
922 With the option @option{--single}, the first and only the first match
923 will be returned.  Unless option @option{--cache-only} is also used, no
924 local lookup will be done in this case.
925
926
927
928 @node Dirmngr ISVALID
929 @subsection Validate a certificate using a CRL or OCSP
930
931 @example
932   ISVALID [--only-ocsp] [--force-default-responder] @var{certid}|@var{certfpr}
933 @end example
934
935 Check whether the certificate described by the @var{certid} has been
936 revoked.  Due to caching, the Dirmngr is able to answer immediately in
937 most cases.
938
939 The @var{certid} is a hex encoded string consisting of two parts,
940 delimited by a single dot.  The first part is the SHA-1 hash of the
941 issuer name and the second part the serial number.
942
943 Alternatively the certificate's SHA-1 fingerprint @var{certfpr} may be
944 given in which case an OCSP request is done before consulting the CRL.
945 If the option @option{--only-ocsp} is given, no fallback to a CRL check
946 will be used.  If the option @option{--force-default-responder} is
947 given, only the default OCSP responder will be used and any other
948 methods of obtaining an OCSP responder URL won't be used.
949
950 @noindent
951 Common return values are:
952
953 @table @code
954 @item GPG_ERR_NO_ERROR (0)
955 This is the positive answer: The certificate is not revoked and we have
956 an up-to-date revocation list for that certificate.  If OCSP was used
957 the responder confirmed that the certificate has not been revoked.
958
959 @item GPG_ERR_CERT_REVOKED
960 This is the negative answer: The certificate has been revoked.  Either
961 it is in a CRL and that list is up to date or an OCSP responder informed
962 us that it has been revoked.
963
964 @item GPG_ERR_NO_CRL_KNOWN
965 No CRL is known for this certificate or the CRL is not valid or out of
966 date.
967
968 @item GPG_ERR_NO_DATA
969 The OCSP responder returned an ``unknown'' status.  This means that it
970 is not aware of the certificate's status.
971
972 @item GPG_ERR_NOT_SUPPORTED
973 This is commonly seen if OCSP support has not been enabled in the
974 configuration.
975 @end table
976
977 If DirMngr has not enough information about the given certificate (which
978 is the case for not yet cached certificates), it will inquire the
979 missing data:
980
981 @example
982   S: INQUIRE SENDCERT <CertID>
983   C: D <DER encoded certificate>
984   C: END
985 @end example
986
987 A client should be aware that DirMngr may ask for more than one
988 certificate.
989
990 If Dirmngr has a certificate but the signature of the certificate
991 could not been validated because the root certificate is not known to
992 dirmngr as trusted, it may ask back to see whether the client trusts
993 this the root certificate:
994
995 @example
996   S: INQUIRE ISTRUSTED <CertHexfpr>
997   C: D 1
998   C: END
999 @end example
1000
1001 Only this answer will let Dirmngr consider the certificate as valid.
1002
1003
1004 @node Dirmngr CHECKCRL
1005 @subsection Validate a certificate using a CRL
1006
1007 Check whether the certificate with FINGERPRINT (SHA-1 hash of the
1008 entire X.509 certificate blob) is valid or not by consulting the CRL
1009 responsible for this certificate.  If the fingerprint has not been
1010 given or the certificate is not known, the function inquires the
1011 certificate using:
1012
1013 @example
1014   S: INQUIRE TARGETCERT
1015   C: D <DER encoded certificate>
1016   C: END
1017 @end example
1018
1019 Thus the caller is expected to return the certificate for the request
1020 (which should match FINGERPRINT) as a binary blob.  Processing then
1021 takes place without further interaction; in particular dirmngr tries
1022 to locate other required certificate by its own mechanism which
1023 includes a local certificate store as well as a list of trusted root
1024 certificates.
1025
1026 @noindent
1027 The return code is 0 for success; i.e. the certificate has not been
1028 revoked or one of the usual error codes from libgpg-error.
1029
1030 @node Dirmngr CHECKOCSP
1031 @subsection Validate a certificate using OCSP
1032
1033 @example
1034   CHECKOCSP [--force-default-responder] [@var{fingerprint}]
1035 @end example
1036
1037 Check whether the certificate with @var{fingerprint} (the SHA-1 hash of
1038 the entire X.509 certificate blob) is valid by consulting the appropriate
1039 OCSP responder.  If the fingerprint has not been given or the
1040 certificate is not known by Dirmngr, the function inquires the
1041 certificate using:
1042
1043 @example
1044   S: INQUIRE TARGETCERT
1045   C: D <DER encoded certificate>
1046   C: END
1047 @end example
1048
1049 Thus the caller is expected to return the certificate for the request
1050 (which should match @var{fingerprint}) as a binary blob.  Processing
1051 then takes place without further interaction; in particular dirmngr
1052 tries to locate other required certificates by its own mechanism which
1053 includes a local certificate store as well as a list of trusted root
1054 certificates.
1055
1056 If the option @option{--force-default-responder} is given, only the
1057 default OCSP responder is used.  This option is the per-command variant
1058 of the global option @option{--ignore-ocsp-service-url}.
1059
1060
1061 @noindent
1062 The return code is 0 for success; i.e. the certificate has not been
1063 revoked or one of the usual error codes from libgpg-error.
1064
1065 @node Dirmngr CACHECERT
1066 @subsection Put a certificate into the internal cache
1067
1068 Put a certificate into the internal cache.  This command might be
1069 useful if a client knows in advance certificates required for a test and
1070 wants to make sure they get added to the internal cache.  It is also
1071 helpful for debugging.  To get the actual certificate, this command
1072 immediately inquires it using
1073
1074 @example
1075   S: INQUIRE TARGETCERT
1076   C: D <DER encoded certificate>
1077   C: END
1078 @end example
1079
1080 Thus the caller is expected to return the certificate for the request
1081 as a binary blob.
1082
1083 @noindent
1084 The return code is 0 for success; i.e. the certificate has not been
1085 successfully cached or one of the usual error codes from libgpg-error.
1086
1087 @node Dirmngr VALIDATE
1088 @subsection Validate a certificate for debugging
1089
1090 Validate a certificate using the certificate validation function used
1091 internally by dirmngr.  This command is only useful for debugging.  To
1092 get the actual certificate, this command immediately inquires it using
1093
1094 @example
1095   S: INQUIRE TARGETCERT
1096   C: D <DER encoded certificate>
1097   C: END
1098 @end example
1099
1100 Thus the caller is expected to return the certificate for the request
1101 as a binary blob.
1102
1103
1104 @mansect see also
1105 @ifset isman
1106 @command{gpgsm}(1),
1107 @command{dirmngr-client}(1)
1108 @end ifset
1109 @include see-also-note.texi
1110
1111 @c
1112 @c !!! UNDER CONSTRUCTION !!!
1113 @c
1114 @c
1115 @c @section Verifying a Certificate
1116 @c
1117 @c There are several ways to request services from Dirmngr.  Almost all of
1118 @c them are done using the Assuan protocol.  What we describe here is the
1119 @c Assuan command CHECKCRL as used for example by the dirmnr-client tool if
1120 @c invoked as
1121 @c
1122 @c @example
1123 @c   dirmngr-client foo.crt
1124 @c @end example
1125 @c
1126 @c This command will send an Assuan request to an already running Dirmngr
1127 @c instance.  foo.crt is expected to be a standard X.509 certificate and
1128 @c dirmngr will receive the Assuan command
1129 @c
1130 @c @example
1131 @c    CHECKCRL @var [{fingerprint}]
1132 @c @end example
1133 @c
1134 @c @var{fingerprint} is optional and expected to be the SHA-1 has of the
1135 @c DER encoding of the certificate under question.  It is to be HEX
1136 @c encoded.  The rationale for sending the fingerprint is that it allows
1137 @c dirmngr to reply immediately if it has already cached such a request.  If
1138 @c this is not the case and no certificate has been found in dirmngr's
1139 @c internal certificate storage, dirmngr will request the certificate using
1140 @c the Assuan inquiry
1141 @c
1142 @c @example
1143 @c       INQUIRE TARGETCERT
1144 @c @end example
1145 @c
1146 @c The caller (in our example dirmngr-client) is then expected to return
1147 @c the certificate for the request (which should match @var{fingerprint})
1148 @c as a binary blob.
1149 @c
1150 @c Dirmngr now passes control to @code{crl_cache_cert_isvalid}.  This
1151 @c function checks whether a CRL item exists for target certificate.  These
1152 @c CRL items are kept in a database of already loaded and verified CRLs.
1153 @c This mechanism is called the CRL cache.  Obviously timestamps are kept
1154 @c there with each item to cope with the expiration date of the CRL.  The
1155 @c possible return values are: @code{0} to indicate that a valid CRL is
1156 @c available for the certificate and the certificate itself is not listed
1157 @c in this CRL, @code{GPG_ERR_CERT_REVOKED} to indicate that the certificate is
1158 @c listed in the CRL or @code{GPG_ERR_NO_CRL_KNOWN} in cases where no CRL or no
1159 @c information is available.  The first two codes are immediately returned to
1160 @c the caller and the processing of this request has been done.
1161 @c
1162 @c Only the @code{GPG_ERR_NO_CRL_KNOWN} needs more attention: Dirmngr now
1163 @c calls @code{clr_cache_reload_crl} and if this succeeds calls
1164 @c @code{crl_cache_cert_isvald) once more.  All further errors are
1165 @c immediately returned to the caller.
1166 @c
1167 @c @code{crl_cache_reload_crl} is the actual heart of the CRL management.
1168 @c It locates the corresponding CRL for the target certificate, reads and
1169 @c verifies this CRL and stores it in the CRL cache.  It works like this:
1170 @c
1171 @c * Loop over all crlDPs in the target certificate.
1172 @c     * If the crlDP is invalid immediately terminate the loop.
1173 @c     * Loop over all names in the current crlDP.
1174 @c         * If the URL scheme is unknown or not enabled
1175 @c           (--ignore-http-dp, --ignore-ldap-dp) continues with
1176 @c           the next name.
1177 @c         * @code{crl_fetch} is called to actually retrieve the CRL.
1178 @c           In case of problems this name is ignore and we continue with
1179 @c           the next name.  Note that @code{crl_fetch} does only return
1180 @c           a descriptor for the CRL for further reading so does the CRL
1181 @c           does not yet end up in memory.
1182 @c         * @code{crl_cache_insert} is called with that descriptor to
1183 @c           actually read the CRL into the cache. See below for a
1184 @c           description of this function.  If there is any error (e.g. read
1185 @c           problem, CRL not correctly signed or verification of signature
1186 @c           not possible), this descriptor is rejected and we continue
1187 @c           with the next name.  If the CRL has been successfully loaded,
1188 @c           the loop is terminated.
1189 @c * If no crlDP has been found in the previous loop use a default CRL.
1190 @c   Note, that if any crlDP has been found but loading of the CRL failed,
1191 @c   this condition is not true.
1192 @c     * Try to load a CRL from all configured servers (ldapservers.conf)
1193 @c       in turn.  The first server returning a CRL is used.
1194 @c     * @code(crl_cache_insert) is then used to actually insert the CRL
1195 @c       into the cache.  If this failed we give up immediately without
1196 @c       checking the rest of the servers from the first step.
1197 @c * Ready.
1198 @c
1199 @c
1200 @c The @code{crl_cache_insert} function takes care of reading the bulk of
1201 @c the CRL, parsing it and checking the signature.  It works like this: A
1202 @c new database file is created using a temporary file name.  The CRL
1203 @c parsing machinery is started and all items of the CRL are put into
1204 @c this database file.  At the end the issuer certificate of the CRL
1205 @c needs to be retrieved.  Three cases are to be distinguished:
1206 @c
1207 @c  a) An authorityKeyIdentifier with an issuer and serialno exits: The
1208 @c     certificate is retrieved using @code{find_cert_bysn}.  If
1209 @c     the certificate is in the certificate cache, it is directly
1210 @c     returned. Then the requester (i.e. the client who requested the
1211 @c     CRL check) is asked via the Assuan inquiry ``SENDCERT'' whether
1212 @c     he can provide this certificate.  If this succeed the returned
1213 @c     certificate gets cached and returned.  Note, that dirmngr does not
1214 @c     verify in any way whether the expected certificate is returned.
1215 @c     It is in the interest of the client to return a useful certificate
1216 @c     as otherwise the service request will fail due to a bad signature.
1217 @c     The last way to get the certificate is by looking it up at
1218 @c     external resources.  This is done using the @code{ca_cert_fetch}
1219 @c     and @code{fetch_next_ksba_cert} and comparing the returned
1220 @c     certificate to match the requested issuer and seriano (This is
1221 @c     needed because the LDAP layer may return several certificates as
1222 @c     LDAP as no standard way to retrieve by serial number).
1223 @c
1224 @c  b) An authorityKeyIdentifier with a key ID exists: The certificate is
1225 @c     retrieved using @code{find_cert_bysubject}.  If the certificate is
1226 @c     in the certificate cache, it is directly returned.  Then the
1227 @c     requester is asked via the Assuan inquiry ``SENDCERT_SKI'' whether
1228 @c     he can provide this certificate.  If this succeed the returned
1229 @c     certificate gets cached and returned.  Note, that dirmngr does not
1230 @c     verify in any way whether the expected certificate is returned.
1231 @c     It is in the interest of the client to return a useful certificate
1232 @c     as otherwise the service request will fail due to a bad signature.
1233 @c     The last way to get the certificate is by looking it up at
1234 @c     external resources.  This is done using the @code{ca_cert_fetch}
1235 @c     and @code{fetch_next_ksba_cert} and comparing the returned
1236 @c     certificate to match the requested subject and key ID.
1237 @c
1238 @c  c) No authorityKeyIdentifier exits: The certificate is retrieved
1239 @c     using @code{find_cert_bysubject} without the key ID argument.  If
1240 @c     the certificate is in the certificate cache the first one with a
1241 @c     matching subject is directly returned.  Then the requester is
1242 @c     asked via the Assuan inquiry ``SENDCERT'' and an exact
1243 @c     specification of the subject whether he can
1244 @c     provide this certificate.  If this succeed the returned
1245 @c     certificate gets cached and returned.  Note, that dirmngr does not
1246 @c     verify in any way whether the expected certificate is returned.
1247 @c     It is in the interest of the client to return a useful certificate
1248 @c     as otherwise the service request will fail due to a bad signature.
1249 @c     The last way to get the certificate is by looking it up at
1250 @c     external resources.  This is done using the @code{ca_cert_fetch}
1251 @c     and @code{fetch_next_ksba_cert} and comparing the returned
1252 @c     certificate to match the requested subject; the first certificate
1253 @c     with a matching subject is then returned.
1254 @c
1255 @c If no certificate was found, the function returns with the error
1256 @c GPG_ERR_MISSING_CERT.  Now the signature is verified.  If this fails,
1257 @c the error is returned.  On success the @code{validate_cert_chain} is
1258 @c used to verify that the certificate is actually valid.
1259 @c
1260 @c Here we may encounter a recursive situation:
1261 @c @code{validate_cert_chain} needs to look at other certificates and
1262 @c also at CRLs to check whether these other certificates and well, the
1263 @c CRL issuer certificate itself are not revoked.  FIXME: We need to make
1264 @c sure that @code{validate_cert_chain} does not try to lookup the CRL we
1265 @c are currently processing. This would be a catch-22 and may indicate a
1266 @c broken PKI.  However, due to overlapping expiring times and imprecise
1267 @c clocks this may actually happen.
1268 @c
1269 @c For historical reasons the Assuan command ISVALID is a bit different
1270 @c to CHECKCRL but this is mainly due to different calling conventions.
1271 @c In the end the same fucntionality is used, albeit hidden by a couple
1272 @c of indirection and argument and result code mangling.  It furthere
1273 @c ingetrages OCSP checking depending on options are the way it is
1274 @c called.  GPGSM still uses this command but might eventually switch over
1275 @c to CHECKCRL and CHECKOCSP so that ISVALID can be retired.
1276 @c
1277 @c
1278 @c @section Validating a certificate
1279 @c
1280 @c We describe here how the internal function @code{validate_cert_chain}
1281 @c works. Note that mainly testing purposes this functionality may be
1282 @c called directly using @cmd{dirmngr-client --validate @file{foo.crt}}.
1283 @c
1284 @c The function takes the target certificate and a mode argument as
1285 @c parameters and returns an error code and optionally the closes
1286 @c expiration time of all certificates in the chain.
1287 @c
1288 @c We first check that the certificate may be used for the requested
1289 @c purpose (i.e. OCSP or CRL signing).  If this is not the case
1290 @c GPG_ERR_WRONG_KEY_USAGE is returned.
1291 @c
1292 @c The next step is to find the trust anchor (root certificate) and to
1293 @c assemble the chain in memory: Starting with the target certificate,
1294 @c the expiration time is checked against the current date, unknown
1295 @c critical extensions are detected and certificate policies are matched
1296 @c (We only allow 2.289.9.9 but I have no clue about that OID and from
1297 @c where I got it - it does not even seem to be assigned - debug cruft?).
1298 @c
1299 @c Now if this certificate is a self-signed one, we have reached the
1300 @c trust anchor.  In this case we check that the signature is good, the
1301 @c certificate is allowed to act as a CA, that it is a trusted one (by
1302 @c checking whether it is has been put into the trusted-certs
1303 @c configuration directory) and finally prepend into to our list
1304 @c representing the certificate chain.  This steps ends then.
1305 @c
1306 @c If it is not a self-signed certificate, we check that the chain won't
1307 @c get too long (current limit is 100), if this is the case we terminate
1308 @c with the error GPG_ERR_BAD_CERT_CHAIN.
1309 @c
1310 @c Now the issuer's certificate is looked up: If an
1311 @c authorityKeyIdentifier is available, this one is used to locate the
1312 @c certificate either using issuer and serialnumber or subject DN
1313 @c (i.e. the issuer's DN) and the keyID.  The functions
1314 @c @code{find_cert_bysn) and @code{find_cert_bysubject} are used
1315 @c respectively. The have already been described above under the
1316 @c description of @code{crl_cache_insert}.  If no certificate was found
1317 @c or with no authorityKeyIdentifier, only the cache is consulted using
1318 @c @code{get_cert_bysubject}.  The latter is done under the assumption
1319 @c that a matching certificate has explicitly been put into the
1320 @c certificate cache.  If the issuer's certificate could not be found,
1321 @c the validation terminates with the error code @code{GPG_ERR_MISSING_CERT}.
1322 @c
1323 @c If the issuer's certificate has been found, the signature of the
1324 @c actual certificate is checked and in case this fails the error
1325 @c #code{GPG_ERR_BAD_CERT_CHAIN} is returned.  If the signature checks out, the
1326 @c maximum chain length of the issuing certificate is checked as well as
1327 @c the capability of the certificate (i.e. whether he may be used for
1328 @c certificate signing).  Then the certificate is prepended to our list
1329 @c representing the certificate chain.  Finally the loop is continued now
1330 @c with the issuer's certificate as the current certificate.
1331 @c
1332 @c After the end of the loop and if no error as been encountered
1333 @c (i.e. the certificate chain has been assempled correctly), a check is
1334 @c done whether any certificate expired or a critical policy has not been
1335 @c met.  In any of these cases the validation terminates with an
1336 @c appropriate error.
1337 @c
1338 @c Finally the function @code{check_revocations} is called to verify no
1339 @c certificate in the assempled chain has been revoked: This is an
1340 @c recursive process because a CRL has to be checked for each certificate
1341 @c in the chain except for the root certificate, of which we already know
1342 @c that it is trusted and we avoid checking a CRL here due to common
1343 @c setup problems and the assumption that a revoked root certificate has
1344 @c been removed from the list of trusted certificates.
1345 @c
1346 @c
1347 @c
1348 @c
1349 @c @section Looking up certificates through LDAP.
1350 @c
1351 @c This describes the LDAP layer to retrieve certificates.
1352 @c the functions @code{ca_cert_fetch} and @code{fetch_next_ksba_cert} are
1353 @c used for this.  The first one starts a search and the second one is
1354 @c used to retrieve certificate after certificate.
1355 @c