Imported Upstream version 2.0.19
[platform/upstream/gpg2.git] / doc / debugging.texi
1 @c Copyright (C) 2004 Free Software Foundation, Inc.
2 @c This is part of the GnuPG manual.
3 @c For copying conditions, see the file gnupg.texi.
4
5 @node Debugging
6 @chapter How to solve problems
7
8 Everyone knows that software often does not do what it should do and thus
9 there is a need to track down problems.  We call this debugging in a
10 reminiscent to the moth jamming a relay in a Mark II box back in 1947.
11
12 Most of the problems a merely configuration and user problems but
13 nevertheless there are the most annoying ones and responsible for many
14 gray hairs.  We try to give some guidelines here on how to identify and
15 solve the problem at hand.
16
17
18 @menu
19 * Debugging Tools::       Description of some useful tools.
20 * Debugging Hints::       Various hints on debugging.
21 * Common Problems::       Commonly seen problems.
22 * Architecture Details::  How the whole thing works internally.
23 @end menu
24
25
26 @node Debugging Tools
27 @section Debugging Tools
28
29 The GnuPG distribution comes with a couple of tools, useful to help find
30 and solving problems.
31
32 @menu
33 * kbxutil::        Scrutinizing a keybox file.
34 @end menu
35
36 @node kbxutil
37 @subsection Scrutinizing a keybox file
38
39 A keybox is a file format used to store public keys along with meta
40 information and indices.  The commonly used one is the file
41 @file{pubring.kbx} in the @file{.gnupg} directory. It contains all
42 X.509 certificates as well as OpenPGP keys@footnote{Well, OpenPGP keys
43 are not implemented, @command{gpg} still used the keyring file
44 @file{pubring.gpg}} .
45
46 @noindent
47 When called the standard way, e.g.:
48
49 @samp{kbxutil ~/.gnupg/pubring.kbx}
50
51 @noindent
52 it lists all records (called @acronym{blobs}) with there meta-information
53 in a human readable format.
54
55 @noindent
56 To see statistics on the keybox in question, run it using
57
58 @samp{kbxutil --stats ~/.gnupg/pubring.kbx}
59
60 @noindent
61 and you get an output like:
62
63 @example
64 Total number of blobs:       99
65                header:        1
66                 empty:        0
67               openpgp:        0
68                  x509:       98
69           non flagged:       81
70        secret flagged:        0
71     ephemeral flagged:       17
72 @end example
73
74 In this example you see that the keybox does not have any OpenPGP keys
75 but contains 98 X.509 certificates and a total of 17 keys or certificates
76 are flagged as ephemeral, meaning that they are only temporary stored
77 (cached) in the keybox and won't get listed using the usual commands
78 provided by @command{gpgsm} or @command{gpg}. 81 certificates are stored
79 in a standard way and directly available from @command{gpgsm}.
80
81 @noindent
82 To find duplicated certificates and keyblocks in a keybox file (this
83 should not occur but sometimes things go wrong), run it using
84
85 @samp{kbxutil --find-dups ~/.gnupg/pubring.kbx}
86
87
88 @node Debugging Hints
89 @section Various hints on debugging.
90
91 @itemize @bullet
92
93 @item How to find the IP address of a keyserver
94
95 If a round robin URL of is used for a keyserver
96 (e.g. subkeys.gnupg.org); it is not easy to see what server is actually
97 used.  Using the keyserver debug option as in
98
99 @smallexample
100  gpg --keyserver-options debug=1 -v --refresh-key 1E42B367
101 @end smallexample
102
103 is thus often helpful.  Note that the actual output depends on the
104 backend and may change from release to release.
105
106 @ifset gpgtwoone
107 @item Logging on WindowsCE
108
109 For development, the best logging method on WindowsCE is the use of
110 remote debugging using a log file name of @file{tcp://<ip-addr>:<port>}.
111 The command @command{watchgnupg} may be used on the remote host to listen
112 on the given port. (@pxref{option watchgnupg --tcp}).  For in the field
113 tests it is better to make use of the logging facility provided by the
114 @command{gpgcedev} driver (part of libassuan); this is enabled by using
115 a log file name of @file{GPG2:}. (@pxref{option --log-file}).
116 @end ifset
117
118 @end itemize
119
120
121 @node Common Problems
122 @section Commonly Seen Problems
123
124
125 @itemize @bullet
126 @item Error code @samp{Not supported} from Dirmngr
127
128 Most likely the option @option{enable-ocsp} is active for gpgsm
129 but Dirmngr's OCSP feature has not been enabled using
130 @option{allow-ocsp} in @file{dirmngr.conf}.
131
132 @item The Curses based Pinentry does not work
133
134 The far most common reason for this is that the environment variable
135 @code{GPG_TTY} has not been set correctly.  Make sure that it has been
136 set to a real tty devce and not just to @samp{/dev/tty};
137 i.e. @samp{GPG_TTY=tty} is plainly wrong; what you want is
138 @samp{GPG_TTY=`tty`} --- note the back ticks.  Also make sure that
139 this environment variable gets exported, that is you should follow up
140 the setting with an @samp{export GPG_TTY} (assuming a Bourne style
141 shell). Even for GUI based Pinentries; you should have set
142 @code{GPG_TTY}. See the section on installing the @command{gpg-agent}
143 on how to do it.
144
145
146 @item SSH hangs while a popping up pinentry was expected
147
148 SSH has no way to tell the gpg-agent what terminal or X display it is
149 running on.  So when remotely logging into a box where a gpg-agent with
150 SSH support is running, the pinentry will get popped up on whatever
151 display the gpg-agent has been started.  To solve this problem you may
152 issue the command
153
154 @smallexample
155 echo UPDATESTARTUPTTY | gpg-connect-agent
156 @end smallexample
157
158 and the next pinentry will pop up on your display or screen. However,
159 you need to kill the running pinentry first because only one pinentry
160 may be running at once.  If you plan to use ssh on a new display you
161 should issue the above command before invoking ssh or any other service
162 making use of ssh.
163
164
165 @item Exporting a secret key without a certificate
166
167 I may happen that you have created a certificate request using
168 @command{gpgsm} but not yet received and imported the certificate from
169 the CA.  However, you want to export the secret key to another machine
170 right now to import the certificate over there then.  You can do this
171 with a little trick but it requires that you know the approximate time
172 you created the signing request.  By running the command
173
174 @smallexample
175   ls -ltr ~/.gnupg/private-keys-v1.d
176 @end smallexample
177
178 you get a listing of all private keys under control of @command{gpg-agent}.
179 Pick the key which best matches the creation time and run the command
180  
181 @smallexample
182   /usr/local/libexec/gpg-protect-tool --p12-export ~/.gnupg/private-keys-v1.d/@var{foo} >@var{foo}.p12
183 @end smallexample
184
185 (Please adjust the path to @command{gpg-protect-tool} to the appropriate
186 location). @var{foo} is the name of the key file you picked (it should
187 have the suffix @file{.key}).  A Pinentry box will pop up and ask you
188 for the current passphrase of the key and a new passphrase to protect it
189 in the pkcs#12 file.
190
191 To import the created file on the machine you use this command:  
192
193 @smallexample
194   /usr/local/libexec/gpg-protect-tool --p12-import --store  @var{foo}.p12
195 @end smallexample
196
197 You will be asked for the pkcs#12 passphrase and a new passphrase to
198 protect the imported private key at its new location.
199
200 Note that there is no easy way to match existing certificates with
201 stored private keys because some private keys are used for Secure Shell
202 or other purposes and don't have a corresponding certificate.
203
204
205 @item A root certificate does not verify
206
207 A common problem is that the root certificate misses the required
208 basicConstraints attribute and thus @command{gpgsm} rejects this
209 certificate.  An error message indicating ``no value'' is a sign for
210 such a certificate.  You may use the @code{relax} flag in
211 @file{trustlist.txt} to accept the certificate anyway.  Note that the
212 fingerprint and this flag may only be added manually to
213 @file{trustlist.txt}.
214
215 @item Error message: ``digest algorithm N has not been enabled''
216
217 The signature is broken.  You may try the option
218 @option{--extra-digest-algo SHA256} to workaround the problem.  The
219 number N is the internal algorithm identifier; for example 8 refers to
220 SHA-256.
221
222
223 @item The Windows version does not work under Wine
224
225 When running the W32 version of @command{gpg} under Wine you may get
226 an error messages like:
227
228 @smallexample
229 gpg: fatal: WriteConsole failed: Access denied
230 @end smallexample
231
232 @noindent
233 The solution is to use the command @command{wineconsole}. 
234
235 Some operations like gen-key really want to talk to the console directly
236 for increased security (for example to prevent the passphrase from
237 appearing on the screen).  So, you should use @command{wineconsole}
238 instead of @command{wine}, which will launch a windows console that
239 implements those additional features.
240
241
242 @item Why does GPG's --search-key list weird keys?
243
244 For performance reasons the keyservers do not check the keys the same
245 way @command{gpg} does.  It may happen that the listing of keys
246 available on the keyservers shows keys with wrong user IDs or with user
247 Ids from other keys.  If you try to import this key, the bad keys or bad
248 user ids won't get imported, though.  This is a bit unfortunate but we
249 can't do anything about it without actually downloading the keys.
250
251 @end itemize
252
253
254 @c ********************************************
255 @c ***  Architecture Details  *****************
256 @c ********************************************
257 @node Architecture Details
258 @section How the whole thing works internally.
259
260
261 @menu
262 * GnuPG-1 and GnuPG-2::   Relationship between the two branches.
263 @end menu
264
265 @node GnuPG-1 and GnuPG-2
266 @subsection  Relationship between the two branches.
267
268 Here is a little picture showing how the components work together:
269
270 @image{gnupg-card-architecture, 10cm}
271
272 @noindent
273 Lets try to explain it:
274
275 TO BE DONE.
276
277