File: dirmngr.texi

package info (click to toggle)
gnupg2 2.2.12-1+deb10u1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 47,236 kB
  • sloc: ansic: 231,709; sh: 7,598; lisp: 6,034; makefile: 1,604; awk: 126; xml: 51; python: 16; sed: 16; php: 14; perl: 13
file content (1181 lines) | stat: -rw-r--r-- 45,032 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
@c Copyright (C) 2002 Klar"alvdalens Datakonsult AB
@c Copyright (C) 2004, 2005, 2006, 2007 g10 Code GmbH
@c This is part of the GnuPG manual.
@c For copying conditions, see the file gnupg.texi.

@include defs.inc

@node Invoking DIRMNGR
@chapter Invoking DIRMNGR
@cindex DIRMNGR command options
@cindex command options
@cindex options, DIRMNGR command

@manpage dirmngr.8
@ifset manverb
.B dirmngr
\- CRL and OCSP daemon
@end ifset

@mansect synopsis
@ifset manverb
.B  dirmngr
.RI [ options ]
.I command
.RI [ args ]
@end ifset

@mansect description
Since version 2.1 of GnuPG, @command{dirmngr} takes care of accessing
the OpenPGP keyservers.  As with previous versions it is also used as
a server for managing and downloading certificate revocation lists
(CRLs) for X.509 certificates, downloading X.509 certificates, and
providing access to OCSP providers.  Dirmngr is invoked internally by
@command{gpg}, @command{gpgsm}, or via the @command{gpg-connect-agent}
tool.

@manpause
@noindent
@xref{Option Index},for an index to @command{DIRMNGR}'s commands and
options.
@mancont

@menu
* Dirmngr Commands::      List of all commands.
* Dirmngr Options::       List of all options.
* Dirmngr Configuration:: Configuration files.
* Dirmngr Signals::       Use of signals.
* Dirmngr Examples::      Some usage examples.
* Dirmngr Protocol::      The protocol dirmngr uses.
@end menu


@node Dirmngr Commands
@section Commands
@mansect commands

Commands are not distinguished from options except for the fact that
only one command is allowed.

@table @gnupgtabopt
@item --version
@opindex version
Print the program version and licensing information.  Note that you cannot
abbreviate this command.

@item --help, -h
@opindex help
Print a usage message summarizing the most useful command-line options.
Note that you cannot abbreviate this command.

@item --dump-options
@opindex dump-options
Print a list of all available options and commands.  Note that you cannot
abbreviate this command.

@item --server
@opindex server
Run in server mode and wait for commands on the @code{stdin}.  The
default mode is to create a socket and listen for commands there.
This is only used for testing.

@item --daemon
@opindex daemon
Run in background daemon mode and listen for commands on a socket.
This is the way @command{dirmngr} is started on demand by the other
GnuPG components.  To force starting @command{dirmngr} it is in
general best to use @code{gpgconf --launch dirmngr}.

@item --supervised
@opindex supervised
Run in the foreground, sending logs to stderr, and listening on file
descriptor 3, which must already be bound to a listening socket.  This
is useful when running under systemd or other similar process
supervision schemes.  This option is not supported on Windows.

@item --list-crls
@opindex list-crls
List the contents of the CRL cache on @code{stdout}. This is probably
only useful for debugging purposes.

@item --load-crl @var{file}
@opindex load-crl
This command requires a filename as additional argument, and it will
make Dirmngr try to import the CRL in @var{file} into it's cache.
Note, that this is only possible if Dirmngr is able to retrieve the
CA's certificate directly by its own means.  In general it is better
to use @code{gpgsm}'s @code{--call-dirmngr loadcrl filename} command
so that @code{gpgsm} can help dirmngr.

@item --fetch-crl @var{url}
@opindex fetch-crl
This command requires an URL as additional argument, and it will make
dirmngr try to retrieve and import the CRL from that @var{url} into
it's cache.  This is mainly useful for debugging purposes.  The
@command{dirmngr-client} provides the same feature for a running dirmngr.

@item --shutdown
@opindex shutdown
This commands shuts down an running instance of Dirmngr.  This command
has currently no effect.

@item --flush
@opindex flush
This command removes all CRLs from Dirmngr's cache.  Client requests
will thus trigger reading of fresh CRLs.

@end table


@mansect options
@node Dirmngr Options
@section Option Summary

Note that all long options with the exception of @option{--options}
and @option{--homedir} may also be given in the configuration file
after stripping off the two leading dashes.

@table @gnupgtabopt

@item --options @var{file}
@opindex options
Reads configuration from @var{file} instead of from the default
per-user configuration file.  The default configuration file is named
@file{dirmngr.conf} and expected in the home directory.

@item --homedir @var{dir}
@opindex options
Set the name of the home directory to @var{dir}.  This option is only
effective when used on the command line.  The default is
the directory named @file{.gnupg} directly below the home directory
of the user unless the environment variable @code{GNUPGHOME} has been set
in which case its value will be used.  Many kinds of data are stored within
this directory.


@item -v
@item --verbose
@opindex v
@opindex verbose
Outputs additional information while running.
You can increase the verbosity by giving several
verbose commands to @sc{dirmngr}, such as @option{-vv}.


@item --log-file @var{file}
@opindex log-file
Append all logging output to @var{file}.  This is very helpful in
seeing what the agent actually does.  Use @file{socket://} to log to
socket.

@item --debug-level @var{level}
@opindex debug-level
Select the debug level for investigating problems.  @var{level} may be a
numeric value or by a keyword:

@table @code
@item none
No debugging at all.  A value of less than 1 may be used instead of
the keyword.
@item basic
Some basic debug messages.  A value between 1 and 2 may be used
instead of the keyword.
@item advanced
More verbose debug messages.  A value between 3 and 5 may be used
instead of the keyword.
@item expert
Even more detailed messages.  A value between 6 and 8 may be used
instead of the keyword.
@item guru
All of the debug messages you can get. A value greater than 8 may be
used instead of the keyword.  The creation of hash tracing files is
only enabled if the keyword is used.
@end table

How these messages are mapped to the actual debugging flags is not
specified and may change with newer releases of this program. They are
however carefully selected to best aid in debugging.

@item --debug @var{flags}
@opindex debug
Set debugging flags.  This option is only useful for debugging and its
behavior may change with a new release.  All flags are or-ed and may
be given in C syntax (e.g. 0x0042) or as a comma separated list of
flag names.  To get a list of all supported flags the single word
"help" can be used.

@item --debug-all
@opindex debug-all
Same as @code{--debug=0xffffffff}

@item --tls-debug @var{level}
@opindex tls-debug
Enable debugging of the TLS layer at @var{level}.  The details of the
debug level depend on the used TLS library and are not set in stone.

@item --debug-wait @var{n}
@opindex debug-wait
When running in server mode, wait @var{n} seconds before entering the
actual processing loop and print the pid.  This gives time to attach a
debugger.

@item --disable-check-own-socket
@opindex disable-check-own-socket
On some platforms @command{dirmngr} is able to detect the removal of
its socket file and shutdown itself.  This option disable this
self-test for debugging purposes.

@item -s
@itemx --sh
@itemx -c
@itemx --csh
@opindex s
@opindex sh
@opindex c
@opindex csh
Format the info output in daemon mode for use with the standard Bourne
shell respective the C-shell. The default is to guess it based on the
environment variable @code{SHELL} which is in almost all cases
sufficient.

@item --force
@opindex force
Enabling this option forces loading of expired CRLs; this is only
useful for debugging.

@item --use-tor
@itemx --no-use-tor
@opindex use-tor
@opindex no-use-tor
The option @option{--use-tor} switches Dirmngr and thus GnuPG into
``Tor mode'' to route all network access via Tor (an anonymity
network).  Certain other features are disabled in this mode.  The
effect of @option{--use-tor} cannot be overridden by any other command
or even by reloading dirmngr.  The use of @option{--no-use-tor}
disables the use of Tor.  The default is to use Tor if it is available
on startup or after reloading dirmngr.

@item --standard-resolver
@opindex standard-resolver
This option forces the use of the system's standard DNS resolver code.
This is mainly used for debugging.  Note that on Windows a standard
resolver is not used and all DNS access will return the error ``Not
Implemented'' if this function is used.

@item --recursive-resolver
@opindex recursive-resolver
When possible use a recursive resolver instead of a stub resolver.

@item --resolver-timeout @var{n}
@opindex resolver-timeout
Set the timeout for the DNS resolver to N seconds.  The default are 30
seconds.

@item --connect-timeout @var{n}
@item --connect-quick-timeout @var{n}
@opindex connect-timeout
@opindex connect-quick-timeout
Set the timeout for HTTP and generic TCP connection attempts to N
seconds.  The value set with the quick variant is used when the
--quick option has been given to certain Assuan commands.  The quick
value is capped at the value of the regular connect timeout.  The
default values are 15 and 2 seconds.  Note that the timeout values are
for each connection attempt; the connection code will attempt to
connect all addresses listed for a server.

@item --listen-backlog @var{n}
@opindex listen-backlog
Set the size of the queue for pending connections.  The default is 64.

@item --allow-version-check
@opindex allow-version-check
Allow Dirmngr to connect to @code{https://versions.gnupg.org} to get
the list of current software versions.
On debian-packaged versions, this option does nothing since software
updates should be handled by the distribution.
See the option
@option{--query-swdb} of the command @command{gpgconf} for more
details.  Note, that regardless of this option a version check can
always be triggered using this command:

@example
       gpg-connect-agent --dirmngr 'loadswdb --force' /bye
@end example


@item --keyserver @var{name}
@opindex keyserver
Use @var{name} as your keyserver.  This is the server that @command{gpg}
communicates with to receive keys, send keys, and search for
keys.  The format of the @var{name} is a URI:
`scheme:[//]keyservername[:port]' The scheme is the type of keyserver:
"hkp" for the HTTP (or compatible) keyservers, "ldap" for the LDAP
keyservers, or "mailto" for the Graff email keyserver. Note that your
particular installation of GnuPG may have other keyserver types
available as well. Keyserver schemes are case-insensitive. After the
keyserver name, optional keyserver configuration options may be
provided.  These are the same as the @option{--keyserver-options} of
@command{gpg}, but apply only to this particular keyserver.

Most keyservers synchronize with each other, so there is generally no
need to send keys to more than one server. The keyserver
@code{hkp://keys.gnupg.net} uses round robin DNS to give a different
keyserver each time you use it.

If exactly two keyservers are configured and only one is a Tor hidden
service (.onion), Dirmngr selects the keyserver to use depending on
whether Tor is locally running or not.  The check for a running Tor is
done for each new connection.

If no keyserver is explicitly configured, dirmngr will use the
built-in default of hkps://keys.openpgp.org.

@item --nameserver @var{ipaddr}
@opindex nameserver
In ``Tor mode'' Dirmngr uses a public resolver via Tor to resolve DNS
names.  If the default public resolver, which is @code{8.8.8.8}, shall
not be used a different one can be given using this option.  Note that
a numerical IP address must be given (IPv6 or IPv4) and that no error
checking is done for @var{ipaddr}.

@item --disable-ipv4
@item --disable-ipv6
@opindex disable-ipv4
@opindex disable-ipv6
Disable the use of all IPv4 or IPv6 addresses.

@item --disable-ldap
@opindex disable-ldap
Entirely disables the use of LDAP.

@item --disable-http
@opindex disable-http
Entirely disables the use of HTTP.

@item --ignore-http-dp
@opindex ignore-http-dp
When looking for the location of a CRL, the to be tested certificate
usually contains so called @dfn{CRL Distribution Point} (DP) entries
which are URLs describing the way to access the CRL.  The first found DP
entry is used.  With this option all entries using the @acronym{HTTP}
scheme are ignored when looking for a suitable DP.

@item --ignore-ldap-dp
@opindex ignore-ldap-dp
This is similar to @option{--ignore-http-dp} but ignores entries using
the @acronym{LDAP} scheme.  Both options may be combined resulting in
ignoring DPs entirely.

@item --ignore-ocsp-service-url
@opindex ignore-ocsp-service-url
Ignore all OCSP URLs contained in the certificate.  The effect is to
force the use of the default responder.

@item --honor-http-proxy
@opindex honor-http-proxy
If the environment variable @env{http_proxy} has been set, use its
value to access HTTP servers.

@item --http-proxy @var{host}[:@var{port}]
@opindex http-proxy
@efindex http_proxy
Use @var{host} and @var{port} to access HTTP servers.  The use of this
option overrides the environment variable @env{http_proxy} regardless
whether @option{--honor-http-proxy} has been set.


@item --ldap-proxy @var{host}[:@var{port}]
@opindex ldap-proxy
Use @var{host} and @var{port} to connect to LDAP servers.  If @var{port}
is omitted, port 389 (standard LDAP port) is used.  This overrides any
specified host and port part in a LDAP URL and will also be used if host
and port have been omitted from the URL.

@item --only-ldap-proxy
@opindex only-ldap-proxy
Never use anything else but the LDAP "proxy" as configured with
@option{--ldap-proxy}.  Usually @command{dirmngr} tries to use other
configured LDAP server if the connection using the "proxy" failed.


@item --ldapserverlist-file @var{file}
@opindex ldapserverlist-file
Read the list of LDAP servers to consult for CRLs and certificates from
file instead of the default per-user ldap server list file. The default
value for @var{file} is @file{dirmngr_ldapservers.conf}.

This server list file contains one LDAP server per line in the format

@sc{hostname:port:username:password:base_dn}

Lines starting with a  @samp{#} are comments.

Note that as usual all strings entered are expected to be UTF-8 encoded.
Obviously this will lead to problems if the password has originally been
encoded as Latin-1.  There is no other solution here than to put such a
password in the binary encoding into the file (i.e. non-ascii characters
won't show up readable).@footnote{The @command{gpgconf} tool might be
helpful for frontends as it enables editing this configuration file using
percent-escaped strings.}


@item --ldaptimeout @var{secs}
@opindex ldaptimeout
Specify the number of seconds to wait for an LDAP query before timing
out.  The default are 15 seconds.  0 will never timeout.


@item --add-servers
@opindex add-servers
This option makes dirmngr add any servers it discovers when validating
certificates against CRLs to the internal list of servers to consult for
certificates and CRLs.

This option is useful when trying to validate a certificate that has
a CRL distribution point that points to a server that is not already
listed in the ldapserverlist. Dirmngr will always go to this server and
try to download the CRL, but chances are high that the certificate used
to sign the CRL is located on the same server. So if dirmngr doesn't add
that new server to list, it will often not be able to verify the
signature of the CRL unless the @code{--add-servers} option is used.

Note: The current version of dirmngr has this option disabled by default.


@item --allow-ocsp
@opindex allow-ocsp
This option enables OCSP support if requested by the client.

OCSP requests are rejected by default because they may violate the
privacy of the user; for example it is possible to track the time when
a user is reading a mail.


@item --ocsp-responder @var{url}
@opindex ocsp-responder
Use @var{url} as the default OCSP Responder if the certificate does
not contain information about an assigned responder.  Note, that
@code{--ocsp-signer} must also be set to a valid certificate.

@item --ocsp-signer @var{fpr}|@var{file}
@opindex ocsp-signer
Use the certificate with the fingerprint @var{fpr} to check the
responses of the default OCSP Responder.  Alternatively a filename can be
given in which case the response is expected to be signed by one of the
certificates described in that file.  Any argument which contains a
slash, dot or tilde is considered a filename.  Usual filename expansion
takes place: A tilde at the start followed by a slash is replaced by the
content of @env{HOME}, no slash at start describes a relative filename
which will be searched at the home directory.  To make sure that the
@var{file} is searched in the home directory, either prepend the name
with "./" or use a name which contains a dot.

If a response has been signed by a certificate described by these
fingerprints no further check upon the validity of this certificate is
done.

The format of the @var{FILE} is a list of SHA-1 fingerprint, one per
line with optional colons between the bytes.  Empty lines and lines
prefix with a hash mark are ignored.


@item --ocsp-max-clock-skew @var{n}
@opindex ocsp-max-clock-skew
The number of seconds a skew between the OCSP responder and them local
clock is accepted.  Default is 600 (10 minutes).

@item --ocsp-max-period @var{n}
@opindex ocsp-max-period
Seconds a response is at maximum considered valid after the time given
in the thisUpdate field.  Default is 7776000 (90 days).

@item --ocsp-current-period @var{n}
@opindex ocsp-current-period
The number of seconds an OCSP response is considered valid after the
time given in the NEXT_UPDATE datum.  Default is 10800 (3 hours).


@item --max-replies @var{n}
@opindex max-replies
Do not return more that @var{n} items in one query.  The default is
10.

@item --ignore-cert-extension @var{oid}
@opindex ignore-cert-extension
Add @var{oid} to the list of ignored certificate extensions.  The
@var{oid} is expected to be in dotted decimal form, like
@code{2.5.29.3}.  This option may be used more than once.  Critical
flagged certificate extensions matching one of the OIDs in the list
are treated as if they are actually handled and thus the certificate
won't be rejected due to an unknown critical extension.  Use this
option with care because extensions are usually flagged as critical
for a reason.

@item --hkp-cacert @var{file}
Use the root certificates in @var{file} for verification of the TLS
certificates used with @code{hkps} (keyserver access over TLS).  If
the file is in PEM format a suffix of @code{.pem} is expected for
@var{file}.  This option may be given multiple times to add more
root certificates.  Tilde expansion is supported.

If no @code{hkp-cacert} directive is present, dirmngr will make a
reasonable choice: if the keyserver in question is the special pool
@code{hkps.pool.sks-keyservers.net}, it will use the bundled root
certificate for that pool.  Otherwise, it will use the system CAs.

@end table


@c
@c Dirmngr Configuration
@c
@mansect files
@node Dirmngr Configuration
@section Configuration

Dirmngr makes use of several directories when running in daemon mode:
There are a few configuration files whih control the operation of
dirmngr.  By default they may all be found in the current home
directory (@pxref{option --homedir}).

@table @file

@item dirmngr.conf
@efindex dirmngr.conf
This is the standard configuration file read by @command{dirmngr} on
startup.  It may contain any valid long option; the leading two dashes
may not be entered and the option may not be abbreviated.  This file
is also read after a @code{SIGHUP} however not all options will
actually have an effect.  This default name may be changed on the
command line (@pxref{option --options}).  You should backup this file.

@item /etc/gnupg/trusted-certs
This directory should be filled with certificates of Root CAs you
are trusting in checking the CRLs and signing OCSP Responses.

Usually these are the same certificates you use with the applications
making use of dirmngr.  It is expected that each of these certificate
files contain exactly one @acronym{DER} encoded certificate in a file
with the suffix @file{.crt} or @file{.der}.  @command{dirmngr} reads
those certificates on startup and when given a SIGHUP.  Certificates
which are not readable or do not make up a proper X.509 certificate
are ignored; see the log file for details.

Applications using dirmngr (e.g. gpgsm) can request these
certificates to complete a trust chain in the same way as with the
extra-certs directory (see below).

Note that for OCSP responses the certificate specified using the option
@option{--ocsp-signer} is always considered valid to sign OCSP requests.

@item /etc/gnupg/extra-certs
This directory may contain extra certificates which are preloaded
into the internal cache on startup. Applications using dirmngr (e.g. gpgsm)
can request cached certificates to complete a trust chain.
This is convenient in cases you have a couple intermediate CA certificates
or certificates usually used to sign OCSP responses.
These certificates are first tried before going
out to the net to look for them.  These certificates must also be
@acronym{DER} encoded and suffixed with @file{.crt} or @file{.der}.

@item ~/.gnupg/crls.d
This directory is used to store cached CRLs.  The @file{crls.d}
part will be created by dirmngr if it does not exists but you need to
make sure that the upper directory exists.

@end table
@manpause

To be able to see what's going on you should create the configure file
@file{~/gnupg/dirmngr.conf} with at least one line:

@example
log-file ~/dirmngr.log
@end example

To be able to perform OCSP requests you probably want to add the line:

@example
allow-ocsp
@end example

To make sure that new options are read and that after the installation
of a new GnuPG versions the installed dirmngr is running, you may want
to kill an existing dirmngr first:

@example
gpgconf --kill dirmngr
@end example

You may check the log file to see whether all desired root
certificates have been loaded correctly.


@c
@c Dirmngr Signals
@c
@mansect signals
@node Dirmngr Signals
@section Use of signals

A running @command{dirmngr} may be controlled by signals, i.e. using
the @command{kill} command to send a signal to the process.

Here is a list of supported signals:

@table @gnupgtabopt

@item SIGHUP
@cpindex SIGHUP
This signal flushes all internally cached CRLs as well as any cached
certificates.  Then the certificate cache is reinitialized as on
startup.  Options are re-read from the configuration file.  Instead of
sending this signal it is better to use
@example
gpgconf --reload dirmngr
@end example

@item SIGTERM
@cpindex SIGTERM
Shuts down the process but waits until all current requests are
fulfilled.  If the process has received 3 of these signals and requests
are still pending, a shutdown is forced.  You may also use
@example
gpgconf --kill dirmngr
@end example
instead of this signal

@item SIGINT
@cpindex SIGINT
Shuts down the process immediately.


@item SIGUSR1
@cpindex SIGUSR1
This prints some caching statistics to the log file.

@end table



@c
@c  Examples
@c
@mansect examples
@node Dirmngr Examples
@section Examples

Here is an example on how to show dirmngr's internal table of OpenPGP
keyserver addresses.  The output is intended for debugging purposes
and not part of a defined API.

@example
  gpg-connect-agent --dirmngr 'keyserver --hosttable' /bye
@end example

To inhibit the use of a particular host you have noticed in one of the
keyserver pools, you may use

@example
 gpg-connect-agent --dirmngr 'keyserver --dead pgpkeys.bnd.de' /bye
@end example

The description of the @code{keyserver} command can be printed using

@example
 gpg-connect-agent --dirmngr 'help keyserver' /bye
@end example



@c
@c  Assuan Protocol
@c
@manpause
@node Dirmngr Protocol
@section Dirmngr's Assuan Protocol

Assuan is the IPC protocol used to access dirmngr.  This is a
description of the commands implemented by dirmngr.

@menu
* Dirmngr LOOKUP::      Look up a certificate via LDAP
* Dirmngr ISVALID::     Validate a certificate using a CRL or OCSP.
* Dirmngr CHECKCRL::    Validate a certificate using a CRL.
* Dirmngr CHECKOCSP::   Validate a certificate using OCSP.
* Dirmngr CACHECERT::   Put a certificate into the internal cache.
* Dirmngr VALIDATE::    Validate a certificate for debugging.
@end menu

@node Dirmngr LOOKUP
@subsection Return the certificate(s) found

Lookup certificate.  To allow multiple patterns (which are ORed)
quoting is required: Spaces are to be translated into "+" or into
"%20"; obviously this requires that the usual escape quoting rules
are applied.  The server responds with:

@example
  S: D <DER encoded certificate>
  S: END
  S: D <second DER encoded certificate>
  S: END
  S: OK
@end example

In this example 2 certificates are returned.  The server may return
any number of certificates; OK will also be returned when no
certificates were found.  The dirmngr might return a status line

@example
  S: S TRUNCATED <n>
@end example


To indicate that the output was truncated to N items due to a
limitation of the server or by an arbitrary set limit.

The option @option{--url} may be used if instead of a search pattern a
complete URL to the certificate is known:

@example
  C: LOOKUP --url CN%3DWerner%20Koch,o%3DIntevation%20GmbH,c%3DDE?userCertificate
@end example

If the option @option{--cache-only} is given, no external lookup is done
so that only certificates from the cache are returned.

With the option @option{--single}, the first and only the first match
will be returned.  Unless option @option{--cache-only} is also used, no
local lookup will be done in this case.



@node Dirmngr ISVALID
@subsection Validate a certificate using a CRL or OCSP

@example
  ISVALID [--only-ocsp] [--force-default-responder] @var{certid}|@var{certfpr}
@end example

Check whether the certificate described by the @var{certid} has been
revoked.  Due to caching, the Dirmngr is able to answer immediately in
most cases.

The @var{certid} is a hex encoded string consisting of two parts,
delimited by a single dot.  The first part is the SHA-1 hash of the
issuer name and the second part the serial number.

Alternatively the certificate's SHA-1 fingerprint @var{certfpr} may be
given in which case an OCSP request is done before consulting the CRL.
If the option @option{--only-ocsp} is given, no fallback to a CRL check
will be used.  If the option @option{--force-default-responder} is
given, only the default OCSP responder will be used and any other
methods of obtaining an OCSP responder URL won't be used.

@noindent
Common return values are:

@table @code
@item GPG_ERR_NO_ERROR (0)
This is the positive answer: The certificate is not revoked and we have
an up-to-date revocation list for that certificate.  If OCSP was used
the responder confirmed that the certificate has not been revoked.

@item GPG_ERR_CERT_REVOKED
This is the negative answer: The certificate has been revoked.  Either
it is in a CRL and that list is up to date or an OCSP responder informed
us that it has been revoked.

@item GPG_ERR_NO_CRL_KNOWN
No CRL is known for this certificate or the CRL is not valid or out of
date.

@item GPG_ERR_NO_DATA
The OCSP responder returned an ``unknown'' status.  This means that it
is not aware of the certificate's status.

@item GPG_ERR_NOT_SUPPORTED
This is commonly seen if OCSP support has not been enabled in the
configuration.
@end table

If DirMngr has not enough information about the given certificate (which
is the case for not yet cached certificates), it will inquire the
missing data:

@example
  S: INQUIRE SENDCERT <CertID>
  C: D <DER encoded certificate>
  C: END
@end example

A client should be aware that DirMngr may ask for more than one
certificate.

If Dirmngr has a certificate but the signature of the certificate
could not been validated because the root certificate is not known to
dirmngr as trusted, it may ask back to see whether the client trusts
this the root certificate:

@example
  S: INQUIRE ISTRUSTED <CertHexfpr>
  C: D 1
  C: END
@end example

Only this answer will let Dirmngr consider the certificate as valid.


@node Dirmngr CHECKCRL
@subsection Validate a certificate using a CRL

Check whether the certificate with FINGERPRINT (SHA-1 hash of the
entire X.509 certificate blob) is valid or not by consulting the CRL
responsible for this certificate.  If the fingerprint has not been
given or the certificate is not known, the function inquires the
certificate using:

@example
  S: INQUIRE TARGETCERT
  C: D <DER encoded certificate>
  C: END
@end example

Thus the caller is expected to return the certificate for the request
(which should match FINGERPRINT) as a binary blob.  Processing then
takes place without further interaction; in particular dirmngr tries
to locate other required certificate by its own mechanism which
includes a local certificate store as well as a list of trusted root
certificates.

@noindent
The return code is 0 for success; i.e. the certificate has not been
revoked or one of the usual error codes from libgpg-error.

@node Dirmngr CHECKOCSP
@subsection Validate a certificate using OCSP

@example
  CHECKOCSP [--force-default-responder] [@var{fingerprint}]
@end example

Check whether the certificate with @var{fingerprint} (the SHA-1 hash of
the entire X.509 certificate blob) is valid by consulting the appropriate
OCSP responder.  If the fingerprint has not been given or the
certificate is not known by Dirmngr, the function inquires the
certificate using:

@example
  S: INQUIRE TARGETCERT
  C: D <DER encoded certificate>
  C: END
@end example

Thus the caller is expected to return the certificate for the request
(which should match @var{fingerprint}) as a binary blob.  Processing
then takes place without further interaction; in particular dirmngr
tries to locate other required certificates by its own mechanism which
includes a local certificate store as well as a list of trusted root
certificates.

If the option @option{--force-default-responder} is given, only the
default OCSP responder is used.  This option is the per-command variant
of the global option @option{--ignore-ocsp-service-url}.


@noindent
The return code is 0 for success; i.e. the certificate has not been
revoked or one of the usual error codes from libgpg-error.

@node Dirmngr CACHECERT
@subsection Put a certificate into the internal cache

Put a certificate into the internal cache.  This command might be
useful if a client knows in advance certificates required for a test and
wants to make sure they get added to the internal cache.  It is also
helpful for debugging.  To get the actual certificate, this command
immediately inquires it using

@example
  S: INQUIRE TARGETCERT
  C: D <DER encoded certificate>
  C: END
@end example

Thus the caller is expected to return the certificate for the request
as a binary blob.

@noindent
The return code is 0 for success; i.e. the certificate has not been
successfully cached or one of the usual error codes from libgpg-error.

@node Dirmngr VALIDATE
@subsection Validate a certificate for debugging

Validate a certificate using the certificate validation function used
internally by dirmngr.  This command is only useful for debugging.  To
get the actual certificate, this command immediately inquires it using

@example
  S: INQUIRE TARGETCERT
  C: D <DER encoded certificate>
  C: END
@end example

Thus the caller is expected to return the certificate for the request
as a binary blob.


@mansect see also
@ifset isman
@command{gpgsm}(1),
@command{dirmngr-client}(1)
@end ifset
@include see-also-note.texi

@c
@c !!! UNDER CONSTRUCTION !!!
@c
@c
@c @section Verifying a Certificate
@c
@c There are several ways to request services from Dirmngr.  Almost all of
@c them are done using the Assuan protocol.  What we describe here is the
@c Assuan command CHECKCRL as used for example by the dirmnr-client tool if
@c invoked as
@c
@c @example
@c   dirmngr-client foo.crt
@c @end example
@c
@c This command will send an Assuan request to an already running Dirmngr
@c instance.  foo.crt is expected to be a standard X.509 certificate and
@c dirmngr will receive the Assuan command
@c
@c @example
@c    CHECKCRL @var [{fingerprint}]
@c @end example
@c
@c @var{fingerprint} is optional and expected to be the SHA-1 has of the
@c DER encoding of the certificate under question.  It is to be HEX
@c encoded.  The rationale for sending the fingerprint is that it allows
@c dirmngr to reply immediately if it has already cached such a request.  If
@c this is not the case and no certificate has been found in dirmngr's
@c internal certificate storage, dirmngr will request the certificate using
@c the Assuan inquiry
@c
@c @example
@c       INQUIRE TARGETCERT
@c @end example
@c
@c The caller (in our example dirmngr-client) is then expected to return
@c the certificate for the request (which should match @var{fingerprint})
@c as a binary blob.
@c
@c Dirmngr now passes control to @code{crl_cache_cert_isvalid}.  This
@c function checks whether a CRL item exists for target certificate.  These
@c CRL items are kept in a database of already loaded and verified CRLs.
@c This mechanism is called the CRL cache.  Obviously timestamps are kept
@c there with each item to cope with the expiration date of the CRL.  The
@c possible return values are: @code{0} to indicate that a valid CRL is
@c available for the certificate and the certificate itself is not listed
@c in this CRL, @code{GPG_ERR_CERT_REVOKED} to indicate that the certificate is
@c listed in the CRL or @code{GPG_ERR_NO_CRL_KNOWN} in cases where no CRL or no
@c information is available.  The first two codes are immediately returned to
@c the caller and the processing of this request has been done.
@c
@c Only the @code{GPG_ERR_NO_CRL_KNOWN} needs more attention: Dirmngr now
@c calls @code{clr_cache_reload_crl} and if this succeeds calls
@c @code{crl_cache_cert_isvald) once more.  All further errors are
@c immediately returned to the caller.
@c
@c @code{crl_cache_reload_crl} is the actual heart of the CRL management.
@c It locates the corresponding CRL for the target certificate, reads and
@c verifies this CRL and stores it in the CRL cache.  It works like this:
@c
@c * Loop over all crlDPs in the target certificate.
@c     * If the crlDP is invalid immediately terminate the loop.
@c     * Loop over all names in the current crlDP.
@c         * If the URL scheme is unknown or not enabled
@c           (--ignore-http-dp, --ignore-ldap-dp) continues with
@c           the next name.
@c         * @code{crl_fetch} is called to actually retrieve the CRL.
@c           In case of problems this name is ignore and we continue with
@c           the next name.  Note that @code{crl_fetch} does only return
@c           a descriptor for the CRL for further reading so does the CRL
@c           does not yet end up in memory.
@c         * @code{crl_cache_insert} is called with that descriptor to
@c           actually read the CRL into the cache. See below for a
@c           description of this function.  If there is any error (e.g. read
@c           problem, CRL not correctly signed or verification of signature
@c           not possible), this descriptor is rejected and we continue
@c           with the next name.  If the CRL has been successfully loaded,
@c           the loop is terminated.
@c * If no crlDP has been found in the previous loop use a default CRL.
@c   Note, that if any crlDP has been found but loading of the CRL failed,
@c   this condition is not true.
@c     * Try to load a CRL from all configured servers (ldapservers.conf)
@c       in turn.  The first server returning a CRL is used.
@c     * @code(crl_cache_insert) is then used to actually insert the CRL
@c       into the cache.  If this failed we give up immediately without
@c       checking the rest of the servers from the first step.
@c * Ready.
@c
@c
@c The @code{crl_cache_insert} function takes care of reading the bulk of
@c the CRL, parsing it and checking the signature.  It works like this: A
@c new database file is created using a temporary file name.  The CRL
@c parsing machinery is started and all items of the CRL are put into
@c this database file.  At the end the issuer certificate of the CRL
@c needs to be retrieved.  Three cases are to be distinguished:
@c
@c  a) An authorityKeyIdentifier with an issuer and serialno exits: The
@c     certificate is retrieved using @code{find_cert_bysn}.  If
@c     the certificate is in the certificate cache, it is directly
@c     returned. Then the requester (i.e. the client who requested the
@c     CRL check) is asked via the Assuan inquiry ``SENDCERT'' whether
@c     he can provide this certificate.  If this succeed the returned
@c     certificate gets cached and returned.  Note, that dirmngr does not
@c     verify in any way whether the expected certificate is returned.
@c     It is in the interest of the client to return a useful certificate
@c     as otherwise the service request will fail due to a bad signature.
@c     The last way to get the certificate is by looking it up at
@c     external resources.  This is done using the @code{ca_cert_fetch}
@c     and @code{fetch_next_ksba_cert} and comparing the returned
@c     certificate to match the requested issuer and seriano (This is
@c     needed because the LDAP layer may return several certificates as
@c     LDAP as no standard way to retrieve by serial number).
@c
@c  b) An authorityKeyIdentifier with a key ID exists: The certificate is
@c     retrieved using @code{find_cert_bysubject}.  If the certificate is
@c     in the certificate cache, it is directly returned.  Then the
@c     requester is asked via the Assuan inquiry ``SENDCERT_SKI'' whether
@c     he can provide this certificate.  If this succeed the returned
@c     certificate gets cached and returned.  Note, that dirmngr does not
@c     verify in any way whether the expected certificate is returned.
@c     It is in the interest of the client to return a useful certificate
@c     as otherwise the service request will fail due to a bad signature.
@c     The last way to get the certificate is by looking it up at
@c     external resources.  This is done using the @code{ca_cert_fetch}
@c     and @code{fetch_next_ksba_cert} and comparing the returned
@c     certificate to match the requested subject and key ID.
@c
@c  c) No authorityKeyIdentifier exits: The certificate is retrieved
@c     using @code{find_cert_bysubject} without the key ID argument.  If
@c     the certificate is in the certificate cache the first one with a
@c     matching subject is directly returned.  Then the requester is
@c     asked via the Assuan inquiry ``SENDCERT'' and an exact
@c     specification of the subject whether he can
@c     provide this certificate.  If this succeed the returned
@c     certificate gets cached and returned.  Note, that dirmngr does not
@c     verify in any way whether the expected certificate is returned.
@c     It is in the interest of the client to return a useful certificate
@c     as otherwise the service request will fail due to a bad signature.
@c     The last way to get the certificate is by looking it up at
@c     external resources.  This is done using the @code{ca_cert_fetch}
@c     and @code{fetch_next_ksba_cert} and comparing the returned
@c     certificate to match the requested subject; the first certificate
@c     with a matching subject is then returned.
@c
@c If no certificate was found, the function returns with the error
@c GPG_ERR_MISSING_CERT.  Now the signature is verified.  If this fails,
@c the erro is returned.  On success the @code{validate_cert_chain} is
@c used to verify that the certificate is actually valid.
@c
@c Here we may encounter a recursive situation:
@c @code{validate_cert_chain} needs to look at other certificates and
@c also at CRLs to check whether these other certificates and well, the
@c CRL issuer certificate itself are not revoked.  FIXME: We need to make
@c sure that @code{validate_cert_chain} does not try to lookup the CRL we
@c are currently processing. This would be a catch-22 and may indicate a
@c broken PKI.  However, due to overlapping expiring times and imprecise
@c clocks this may actually happen.
@c
@c For historical reasons the Assuan command ISVALID is a bit different
@c to CHECKCRL but this is mainly due to different calling conventions.
@c In the end the same fucntionality is used, albeit hidden by a couple
@c of indirection and argument and result code mangling.  It furthere
@c ingetrages OCSP checking depending on options are the way it is
@c called.  GPGSM still uses this command but might eventuall switch over
@c to CHECKCRL and CHECKOCSP so that ISVALID can be retired.
@c
@c
@c @section Validating a certificate
@c
@c We describe here how the internal function @code{validate_cert_chain}
@c works. Note that mainly testing purposes this functionality may be
@c called directly using @cmd{dirmngr-client --validate @file{foo.crt}}.
@c
@c The function takes the target certificate and a mode argument as
@c parameters and returns an error code and optionally the closes
@c expiration time of all certificates in the chain.
@c
@c We first check that the certificate may be used for the requested
@c purpose (i.e. OCSP or CRL signing).  If this is not the case
@c GPG_ERR_WRONG_KEY_USAGE is returned.
@c
@c The next step is to find the trust anchor (root certificate) and to
@c assemble the chain in memory: Starting with the target certificate,
@c the expiration time is checked against the current date, unknown
@c critical extensions are detected and certificate policies are matched
@c (We only allow 2.289.9.9 but I have no clue about that OID and from
@c where I got it - it does not even seem to be assigned - debug cruft?).
@c
@c Now if this certificate is a self-signed one, we have reached the
@c trust anchor.  In this case we check that the signature is good, the
@c certificate is allowed to act as a CA, that it is a trusted one (by
@c checking whether it is has been put into the trusted-certs
@c configuration directory) and finally prepend into to our list
@c representing the certificate chain.  This steps ends then.
@c
@c If it is not a self-signed certificate, we check that the chain won't
@c get too long (current limit is 100), if this is the case we terminate
@c with the error GPG_ERR_BAD_CERT_CHAIN.
@c
@c Now the issuer's certificate is looked up: If an
@c authorityKeyIdentifier is available, this one is used to locate the
@c certificate either using issuer and serialnumber or subject DN
@c (i.e. the issuer's DN) and the keyID.  The functions
@c @code{find_cert_bysn) and @code{find_cert_bysubject} are used
@c respectively. The have already been described above under the
@c description of @code{crl_cache_insert}.  If no certificate was found
@c or with no authorityKeyIdentifier, only the cache is consulted using
@c @code{get_cert_bysubject}.  The latter is done under the assumption
@c that a matching certificate has explicitly been put into the
@c certificate cache.  If the issuer's certificate could not be found,
@c the validation terminates with the error code @code{GPG_ERR_MISSING_CERT}.
@c
@c If the issuer's certificate has been found, the signature of the
@c actual certificate is checked and in case this fails the error
@c #code{GPG_ERR_BAD_CERT_CHAIN} is returned.  If the signature checks out, the
@c maximum chain length of the issuing certificate is checked as well as
@c the capability of the certificate (i.e. whether he may be used for
@c certificate signing).  Then the certificate is prepended to our list
@c representing the certificate chain.  Finally the loop is continued now
@c with the issuer's certificate as the current certificate.
@c
@c After the end of the loop and if no error as been encountered
@c (i.e. the certificate chain has been assempled correctly), a check is
@c done whether any certificate expired or a critical policy has not been
@c met.  In any of these cases the validation terminates with an
@c appropriate error.
@c
@c Finally the function @code{check_revocations} is called to verify no
@c certificate in the assempled chain has been revoked: This is an
@c recursive process because a CRL has to be checked for each certificate
@c in the chain except for the root certificate, of which we already know
@c that it is trusted and we avoid checking a CRL here due to common
@c setup problems and the assumption that a revoked root certificate has
@c been removed from the list of trusted certificates.
@c
@c
@c
@c
@c @section Looking up certificates through LDAP.
@c
@c This describes the LDAP layer to retrieve certificates.
@c the functions @code{ca_cert_fetch} and @code{fetch_next_ksba_cert} are
@c used for this.  The first one starts a search and the second one is
@c used to retrieve certificate after certificate.
@c