Imported Upstream version 2.0.19
[platform/upstream/gpg2.git] / doc / gpgsm.texi
1 @c Copyright (C) 2002 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 Invoking GPGSM
6 @chapter Invoking GPGSM
7 @cindex GPGSM command options
8 @cindex command options
9 @cindex options, GPGSM command
10
11 @manpage gpgsm.1
12 @ifset manverb
13 .B gpgsm
14 \- CMS encryption and signing tool
15 @end ifset
16
17 @mansect synopsis
18 @ifset manverb
19 .B  gpgsm
20 .RB [ \-\-homedir
21 .IR dir ]
22 .RB [ \-\-options
23 .IR file ]
24 .RI [ options ]
25 .I command
26 .RI [ args ]
27 @end ifset
28
29
30 @mansect description
31 @command{gpgsm} is a tool similar to @command{gpg} to provide digital
32 encryption and signing services on X.509 certificates and the CMS
33 protocol.  It is mainly used as a backend for S/MIME mail processing.
34 @command{gpgsm} includes a full featured certificate management and
35 complies with all rules defined for the German Sphinx project.
36
37 @manpause
38 @xref{Option Index}, for an index to @command{GPGSM}'s commands and options.
39 @mancont
40
41 @menu
42 * GPGSM Commands::        List of all commands.
43 * GPGSM Options::         List of all options.
44 * GPGSM Configuration::   Configuration files.
45 * GPGSM Examples::        Some usage examples.
46
47 Developer information:
48 * Unattended Usage::      Using @command{gpgsm} from other programs.
49 * GPGSM Protocol::        The protocol the server mode uses.
50 @end menu
51
52 @c *******************************************
53 @c ***************            ****************
54 @c ***************  COMMANDS  ****************
55 @c ***************            ****************
56 @c *******************************************
57 @mansect commands
58 @node GPGSM Commands
59 @section Commands
60
61 Commands are not distinguished from options except for the fact that
62 only one command is allowed.
63
64 @menu
65 * General GPGSM Commands::        Commands not specific to the functionality.
66 * Operational GPGSM Commands::    Commands to select the type of operation.
67 * Certificate Management::        How to manage certificates.
68 @end menu
69
70
71 @c *******************************************
72 @c **********  GENERAL COMMANDS  *************
73 @c *******************************************
74 @node General GPGSM Commands
75 @subsection Commands not specific to the function
76
77 @table @gnupgtabopt
78 @item --version
79 @opindex version
80 Print the program version and licensing information.  Note that you
81 cannot abbreviate this command.
82
83 @item --help, -h
84 @opindex help
85 Print a usage message summarizing the most useful command-line options.
86 Note that you cannot abbreviate this command.
87
88 @item --warranty
89 @opindex warranty
90 Print warranty information.  Note that you cannot abbreviate this
91 command.
92
93 @item --dump-options
94 @opindex dump-options
95 Print a list of all available options and commands.  Note that you cannot
96 abbreviate this command.
97 @end table
98
99
100 @c *******************************************
101 @c ********  OPERATIONAL COMMANDS  ***********
102 @c *******************************************
103 @node Operational GPGSM Commands
104 @subsection Commands to select the type of operation
105
106 @table @gnupgtabopt
107 @item --encrypt
108 @opindex encrypt
109 Perform an encryption.  The keys the data is encrypted too must be set
110 using the option @option{--recipient}.
111
112 @item --decrypt
113 @opindex decrypt
114 Perform a decryption; the type of input is automatically determined.  It
115 may either be in binary form or PEM encoded; automatic determination of
116 base-64 encoding is not done.
117
118 @item --sign
119 @opindex sign
120 Create a digital signature.  The key used is either the fist one found
121 in the keybox or those set with the @option{--local-user} option.
122
123 @item --verify
124 @opindex verify
125 Check a signature file for validity.  Depending on the arguments a
126 detached signature may also be checked.
127
128 @item --server
129 @opindex server
130 Run in server mode and wait for commands on the @code{stdin}.
131
132 @item --call-dirmngr @var{command} [@var{args}]
133 @opindex call-dirmngr
134 Behave as a Dirmngr client issuing the request @var{command} with the
135 optional list of @var{args}.  The output of the Dirmngr is printed
136 stdout.  Please note that file names given as arguments should have an
137 absolute file name (i.e. commencing with @code{/} because they are
138 passed verbatim to the Dirmngr and the working directory of the
139 Dirmngr might not be the same as the one of this client.  Currently it
140 is not possible to pass data via stdin to the Dirmngr.  @var{command}
141 should not contain spaces.
142
143 This is command is required for certain maintaining tasks of the dirmngr
144 where a dirmngr must be able to call back to @command{gpgsm}.  See the Dirmngr
145 manual for details.
146
147 @item --call-protect-tool @var{arguments}
148 @opindex call-protect-tool
149 Certain maintenance operations are done by an external program call
150 @command{gpg-protect-tool}; this is usually not installed in a directory
151 listed in the PATH variable.  This command provides a simple wrapper to
152 access this tool.  @var{arguments} are passed verbatim to this command;
153 use @samp{--help} to get a list of supported operations.
154
155
156 @end table
157
158
159 @c *******************************************
160 @c *******  CERTIFICATE MANAGEMENT  **********
161 @c *******************************************
162 @node Certificate Management
163 @subsection How to manage the certificates and keys
164
165 @table @gnupgtabopt
166 @item --gen-key
167 @opindex gen-key
168 @ifclear gpgtwoone
169 -This command allows the creation of a certificate signing request.  It
170 -is commonly used along with the @option{--output} option to save the
171 -created CSR into a file.  If used with the @option{--batch} a parameter
172 -file is used to create the CSR.
173 @end ifclear
174 @ifset gpgtwoone
175 This command allows the creation of a certificate signing request or a
176 self-signed certificate.  It is commonly used along with the
177 @option{--output} option to save the created CSR or certificate into a
178 file.  If used with the @option{--batch} a parameter file is used to
179 create the CSR or certificate and it is further possible to create
180 non-self-signed certificates.
181 @end ifset
182
183 @item --list-keys
184 @itemx -k
185 @opindex list-keys
186 List all available certificates stored in the local key database.
187 Note that the displayed data might be reformatted for better human
188 readability and illegal characters are replaced by safe substitutes.
189
190 @item --list-secret-keys
191 @itemx -K
192 @opindex list-secret-keys
193 List all available certificates for which a corresponding a secret key
194 is available.
195
196 @item --list-external-keys @var{pattern}
197 @opindex list-keys
198 List certificates matching @var{pattern} using an external server.  This
199 utilizes the @code{dirmngr} service.
200
201 @item --list-chain
202 @opindex list-chain
203 Same as @option{--list-keys} but also prints all keys making up the chain.
204
205
206 @item --dump-cert
207 @itemx --dump-keys
208 @opindex dump-cert
209 @opindex dump-keys
210 List all available certificates stored in the local key database using a
211 format useful mainly for debugging.
212
213 @item --dump-chain
214 @opindex dump-chain
215 Same as @option{--dump-keys} but also prints all keys making up the chain.
216
217 @item --dump-secret-keys
218 @opindex dump-secret-keys
219 List all available certificates for which a corresponding a secret key
220 is available using a format useful mainly for debugging.
221
222 @item --dump-external-keys @var{pattern}
223 @opindex dump-external-keys
224 List certificates matching @var{pattern} using an external server.
225 This utilizes the @code{dirmngr} service.  It uses a format useful
226 mainly for debugging.
227
228 @item --keydb-clear-some-cert-flags
229 @opindex keydb-clear-some-cert-flags
230 This is a debugging aid to reset certain flags in the key database
231 which are used to cache certain certificate stati.  It is especially
232 useful if a bad CRL or a weird running OCSP responder did accidentally
233 revoke certificate.  There is no security issue with this command
234 because @command{gpgsm} always make sure that the validity of a certificate is
235 checked right before it is used.
236
237 @item --delete-keys @var{pattern}
238 @opindex delete-keys
239 Delete the keys matching @var{pattern}.  Note that there is no command
240 to delete the secret part of the key directly.  In case you need to do
241 this, you should run the command @code{gpgsm --dump-secret-keys KEYID}
242 before you delete the key, copy the string of hex-digits in the
243 ``keygrip'' line and delete the file consisting of these hex-digits
244 and the suffix @code{.key} from the @file{private-keys-v1.d} directory
245 below our GnuPG home directory (usually @file{~/.gnupg}).
246
247 @item --export [@var{pattern}]
248 @opindex export
249 Export all certificates stored in the Keybox or those specified by the
250 optional @var{pattern}. Those pattern consist of a list of user ids
251 (@pxref{how-to-specify-a-user-id}).  When used along with the
252 @option{--armor} option a few informational lines are prepended before
253 each block.  There is one limitation: As there is no commonly agreed
254 upon way to pack more than one certificate into an ASN.1 structure,
255 the binary export (i.e. without using @option{armor}) works only for
256 the export of one certificate.  Thus it is required to specify a
257 @var{pattern} which yields exactly one certificate.  Ephemeral
258 certificate are only exported if all @var{pattern} are given as
259 fingerprints or keygrips.
260
261 @item --export-secret-key-p12 @var{key-id}
262 @opindex export
263 Export the private key and the certificate identified by @var{key-id} in
264 a PKCS#12 format. When using along with the @code{--armor} option a few
265 informational lines are prepended to the output.  Note, that the PKCS#12
266 format is not very secure and this command is only provided if there is
267 no other way to exchange the private key. (@pxref{option --p12-charset})
268
269 @item --import [@var{files}]
270 @opindex import
271 Import the certificates from the PEM or binary encoded files as well as
272 from signed-only messages.  This command may also be used to import a
273 secret key from a PKCS#12 file.
274
275 @item --learn-card
276 @opindex learn-card
277 Read information about the private keys from the smartcard and import
278 the certificates from there.  This command utilizes the @command{gpg-agent}
279 and in turn the @command{scdaemon}.
280
281 @item --passwd @var{user_id}
282 @opindex passwd
283 Change the passphrase of the private key belonging to the certificate
284 specified as @var{user_id}.  Note, that changing the passphrase/PIN of a
285 smartcard is not yet supported.
286
287 @end table
288
289
290 @c *******************************************
291 @c ***************            ****************
292 @c ***************  OPTIONS   ****************
293 @c ***************            ****************
294 @c *******************************************
295 @mansect options
296 @node GPGSM Options
297 @section Option Summary
298
299 @command{GPGSM} features a bunch of options to control the exact behaviour
300 and to change the default configuration.
301
302 @menu
303 * Configuration Options::   How to change the configuration.
304 * Certificate Options::     Certificate related options.
305 * Input and Output::        Input and Output.
306 * CMS Options::             How to change how the CMS is created.
307 * Esoteric Options::        Doing things one usually do not want to do.
308 @end menu
309
310
311 @c *******************************************
312 @c ********  CONFIGURATION OPTIONS  **********
313 @c *******************************************
314 @node Configuration Options
315 @subsection How to change the configuration
316
317 These options are used to change the configuration and are usually found
318 in the option file.
319
320 @table @gnupgtabopt
321
322 @item --options @var{file}
323 @opindex options
324 Reads configuration from @var{file} instead of from the default
325 per-user configuration file.  The default configuration file is named
326 @file{gpgsm.conf} and expected in the @file{.gnupg} directory directly
327 below the home directory of the user.
328
329 @include opt-homedir.texi
330
331
332 @item -v
333 @item --verbose
334 @opindex v
335 @opindex verbose
336 Outputs additional information while running.
337 You can increase the verbosity by giving several
338 verbose commands to @command{gpgsm}, such as @samp{-vv}.
339
340 @item --policy-file @var{filename}
341 @opindex policy-file
342 Change the default name of the policy file to @var{filename}.
343
344 @item --agent-program @var{file}
345 @opindex agent-program
346 Specify an agent program to be used for secret key operations.  The
347 default value is the @file{/usr/local/bin/gpg-agent}.  This is only used
348 as a fallback when the environment variable @code{GPG_AGENT_INFO} is not
349 set or a running agent cannot be connected.
350
351 @item --dirmngr-program @var{file}
352 @opindex dirmnr-program
353 Specify a dirmngr program to be used for @acronym{CRL} checks.  The
354 default value is @file{/usr/sbin/dirmngr}.  This is only used as a
355 fallback when the environment variable @code{DIRMNGR_INFO} is not set or
356 a running dirmngr cannot be connected.
357
358 @item --prefer-system-dirmngr
359 @opindex prefer-system-dirmngr
360 If a system wide @command{dirmngr} is running in daemon mode, first try
361 to connect to this one.  Fallback to a pipe based server if this does
362 not work.  Under Windows this option is ignored because the system dirmngr is
363 always used.
364
365 @item --disable-dirmngr
366 Entirely disable the use of the Dirmngr.
367
368 @item --no-secmem-warning
369 @opindex no-secmem-warning
370 Do not print a warning when the so called "secure memory" cannot be used.
371
372 @item --log-file @var{file}
373 @opindex log-file
374 When running in server mode, append all logging output to @var{file}.
375
376 @end table
377
378
379 @c *******************************************
380 @c ********  CERTIFICATE OPTIONS  ************
381 @c *******************************************
382 @node Certificate Options
383 @subsection Certificate related options
384
385 @table @gnupgtabopt
386
387 @item  --enable-policy-checks
388 @itemx --disable-policy-checks
389 @opindex enable-policy-checks
390 @opindex disable-policy-checks
391 By default policy checks are enabled.  These options may be used to
392 change it.
393
394 @item  --enable-crl-checks
395 @itemx --disable-crl-checks
396 @opindex enable-crl-checks
397 @opindex disable-crl-checks
398 By default the @acronym{CRL} checks are enabled and the DirMngr is used
399 to check for revoked certificates.  The disable option is most useful
400 with an off-line network connection to suppress this check.
401
402 @item  --enable-trusted-cert-crl-check
403 @itemx --disable-trusted-cert-crl-check
404 @opindex enable-trusted-cert-crl-check
405 @opindex disable-trusted-cert-crl-check
406 By default the @acronym{CRL} for trusted root certificates are checked
407 like for any other certificates.  This allows a CA to revoke its own
408 certificates voluntary without the need of putting all ever issued
409 certificates into a CRL.  The disable option may be used to switch this
410 extra check off.  Due to the caching done by the Dirmngr, there will not be
411 any noticeable performance gain.  Note, that this also disables possible
412 OCSP checks for trusted root certificates.  A more specific way of
413 disabling this check is by adding the ``relax'' keyword to the root CA
414 line of the @file{trustlist.txt}
415
416
417 @item --force-crl-refresh
418 @opindex force-crl-refresh
419 Tell the dirmngr to reload the CRL for each request.  For better
420 performance, the dirmngr will actually optimize this by suppressing
421 the loading for short time intervals (e.g. 30 minutes). This option
422 is useful to make sure that a fresh CRL is available for certificates
423 hold in the keybox.  The suggested way of doing this is by using it
424 along with the option @option{--with-validation} for a key listing
425 command.  This option should not be used in a configuration file.
426
427 @item  --enable-ocsp
428 @itemx --disable-ocsp
429 @opindex enable-ocsp
430 @opindex disable-ocsp
431 By default @acronym{OCSP} checks are disabled.  The enable option may
432 be used to enable OCSP checks via Dirmngr.  If @acronym{CRL} checks
433 are also enabled, CRLs will be used as a fallback if for some reason an
434 OCSP request will not succeed.  Note, that you have to allow OCSP
435 requests in Dirmngr's configuration too (option
436 @option{--allow-ocsp}) and configure Dirmngr properly.  If you do not do
437 so you will get the error code @samp{Not supported}.
438
439 @item --auto-issuer-key-retrieve
440 @opindex auto-issuer-key-retrieve
441 If a required certificate is missing while validating the chain of
442 certificates, try to load that certificate from an external location.
443 This usually means that Dirmngr is employed to search for the
444 certificate.  Note that this option makes a "web bug" like behavior
445 possible.  LDAP server operators can see which keys you request, so by
446 sending you a message signed by a brand new key (which you naturally
447 will not have on your local keybox), the operator can tell both your IP
448 address and the time when you verified the signature.
449
450
451 @item --validation-model @var{name}
452 @opindex validation-model
453 This option changes the default validation model.  The only possible
454 values are "shell" (which is the default), "chain" which forces the
455 use of the chain model and "steed" for a new simplified model.  The
456 chain model is also used if an option in the @file{trustlist.txt} or
457 an attribute of the certificate requests it.  However the standard
458 model (shell) is in that case always tried first.
459
460 @item --ignore-cert-extension @var{oid}
461 @opindex ignore-cert-extension
462 Add @var{oid} to the list of ignored certificate extensions.  The
463 @var{oid} is expected to be in dotted decimal form, like
464 @code{2.5.29.3}.  This option may be used more than once.  Critical
465 flagged certificate extensions matching one of the OIDs in the list
466 are treated as if they are actually handled and thus the certificate
467 will not be rejected due to an unknown critical extension.  Use this
468 option with care because extensions are usually flagged as critical
469 for a reason.
470
471 @end table
472
473 @c *******************************************
474 @c ***********  INPUT AND OUTPUT  ************
475 @c *******************************************
476 @node Input and Output
477 @subsection Input and Output
478
479 @table @gnupgtabopt
480 @item --armor
481 @itemx -a
482 @opindex armor
483 Create PEM encoded output.  Default is binary output.
484
485 @item --base64
486 @opindex base64
487 Create Base-64 encoded output; i.e. PEM without the header lines.
488
489 @item --assume-armor
490 @opindex assume-armor
491 Assume the input data is PEM encoded.  Default is to autodetect the
492 encoding but this is may fail.
493
494 @item --assume-base64
495 @opindex assume-base64
496 Assume the input data is plain base-64 encoded.
497
498 @item --assume-binary
499 @opindex assume-binary
500 Assume the input data is binary encoded.
501
502 @anchor{option --p12-charset}
503 @item --p12-charset @var{name}
504 @opindex p12-charset
505 @command{gpgsm} uses the UTF-8 encoding when encoding passphrases for
506 PKCS#12 files.  This option may be used to force the passphrase to be
507 encoded in the specified encoding @var{name}.  This is useful if the
508 application used to import the key uses a different encoding and thus
509 will not be able to import a file generated by @command{gpgsm}.  Commonly
510 used values for @var{name} are @code{Latin1} and @code{CP850}.  Note
511 that @command{gpgsm} itself automagically imports any file with a
512 passphrase encoded to the most commonly used encodings.
513
514
515 @item --default-key @var{user_id}
516 @opindex default-key
517 Use @var{user_id} as the standard key for signing.  This key is used if
518 no other key has been defined as a signing key.  Note, that the first
519 @option{--local-users} option also sets this key if it has not yet been
520 set; however @option{--default-key} always overrides this.
521
522
523 @item --local-user @var{user_id}
524 @item -u @var{user_id}
525 @opindex local-user
526 Set the user(s) to be used for signing.  The default is the first
527 secret key found in the database.
528
529
530 @item --recipient @var{name}
531 @itemx -r
532 @opindex recipient
533 Encrypt to the user id @var{name}.  There are several ways a user id
534 may be given (@pxref{how-to-specify-a-user-id}).
535
536
537 @item --output @var{file}
538 @itemx -o @var{file}
539 @opindex output
540 Write output to @var{file}.  The default is to write it to stdout.
541
542
543 @item --with-key-data
544 @opindex with-key-data
545 Displays extra information with the @code{--list-keys} commands.  Especially
546 a line tagged @code{grp} is printed which tells you the keygrip of a
547 key.  This string is for example used as the file name of the
548 secret key.
549
550 @item --with-validation
551 @opindex with-validation
552 When doing a key listing, do a full validation check for each key and
553 print the result.  This is usually a slow operation because it
554 requires a CRL lookup and other operations.
555
556 When used along with --import, a validation of the certificate to
557 import is done and only imported if it succeeds the test.  Note that
558 this does not affect an already available certificate in the DB.
559 This option is therefore useful to simply verify a certificate.
560
561
562 @item --with-md5-fingerprint
563 For standard key listings, also print the MD5 fingerprint of the
564 certificate.
565
566 @item --with-keygrip
567 Include the keygrip in standard key listings.  Note that the keygrip is
568 always listed in --with-colons mode.
569
570 @end table
571
572 @c *******************************************
573 @c *************  CMS OPTIONS  ***************
574 @c *******************************************
575 @node CMS Options
576 @subsection How to change how the CMS is created.
577
578 @table @gnupgtabopt
579 @item --include-certs @var{n}
580 @opindex include-certs
581 Using @var{n} of -2 includes all certificate except for the root cert,
582 -1 includes all certs, 0 does not include any certs, 1 includes only the
583 signers cert and all other positive values include up to @var{n}
584 certificates starting with the signer cert.  The default is -2.
585
586 @item --cipher-algo @var{oid}
587 @opindex cipher-algo
588 Use the cipher algorithm with the ASN.1 object identifier @var{oid} for
589 encryption.  For convenience the strings @code{3DES}, @code{AES} and
590 @code{AES256} may be used instead of their OIDs.  The default is
591 @code{3DES} (1.2.840.113549.3.7).
592
593 @item --digest-algo @code{name}
594 Use @code{name} as the message digest algorithm.  Usually this
595 algorithm is deduced from the respective signing certificate.  This
596 option forces the use of the given algorithm and may lead to severe
597 interoperability problems.
598
599 @end table
600
601
602
603 @c *******************************************
604 @c ********  ESOTERIC OPTIONS  ***************
605 @c *******************************************
606 @node Esoteric Options
607 @subsection Doing things one usually do not want to do.
608
609
610 @table @gnupgtabopt
611
612 @item --extra-digest-algo @var{name}
613 @opindex extra-digest-algo
614 Sometimes signatures are broken in that they announce a different digest
615 algorithm than actually used.  @command{gpgsm} uses a one-pass data
616 processing model and thus needs to rely on the announced digest
617 algorithms to properly hash the data.  As a workaround this option may
618 be used to tell gpg to also hash the data using the algorithm
619 @var{name}; this slows processing down a little bit but allows to verify
620 such broken signatures.  If @command{gpgsm} prints an error like
621 ``digest algo 8 has not been enabled'' you may want to try this option,
622 with @samp{SHA256} for @var{name}.
623
624
625 @item --faked-system-time @var{epoch}
626 @opindex faked-system-time
627 This option is only useful for testing; it sets the system time back or
628 forth to @var{epoch} which is the number of seconds elapsed since the year
629 1970.  Alternatively @var{epoch} may be given as a full ISO time string
630 (e.g. "20070924T154812").
631
632 @item --with-ephemeral-keys
633 @opindex with-ephemeral-keys
634 Include ephemeral flagged keys in the output of key listings.  Note
635 that they are included anyway if the key specification for a listing
636 is given as fingerprint or keygrip.
637
638 @item --debug-level @var{level}
639 @opindex debug-level
640 Select the debug level for investigating problems. @var{level} may be
641 a numeric value or by a keyword:
642
643 @table @code
644 @item none
645 No debugging at all.  A value of less than 1 may be used instead of
646 the keyword.
647 @item basic
648 Some basic debug messages.  A value between 1 and 2 may be used
649 instead of the keyword.
650 @item advanced
651 More verbose debug messages.  A value between 3 and 5 may be used
652 instead of the keyword.
653 @item expert
654 Even more detailed messages.  A value between 6 and 8 may be used
655 instead of the keyword.
656 @item guru
657 All of the debug messages you can get. A value greater than 8 may be
658 used instead of the keyword.  The creation of hash tracing files is
659 only enabled if the keyword is used.
660 @end table
661
662 How these messages are mapped to the actual debugging flags is not
663 specified and may change with newer releases of this program. They are
664 however carefully selected to best aid in debugging.
665
666 @item --debug @var{flags}
667 @opindex debug
668 This option is only useful for debugging and the behaviour may change
669 at any time without notice; using @code{--debug-levels} is the
670 preferred method to select the debug verbosity.  FLAGS are bit encoded
671 and may be given in usual C-Syntax. The currently defined bits are:
672
673 @table @code
674 @item 0  (1)
675 X.509 or OpenPGP protocol related data
676 @item 1  (2)
677 values of big number integers
678 @item 2  (4)
679 low level crypto operations
680 @item 5  (32)
681 memory allocation
682 @item 6  (64)
683 caching
684 @item 7  (128)
685 show memory statistics.
686 @item 9  (512)
687 write hashed data to files named @code{dbgmd-000*}
688 @item 10 (1024)
689 trace Assuan protocol
690 @end table
691
692 Note, that all flags set using this option may get overridden by
693 @code{--debug-level}.
694
695 @item --debug-all
696 @opindex debug-all
697 Same as @code{--debug=0xffffffff}
698
699 @item --debug-allow-core-dump
700 @opindex debug-allow-core-dump
701 Usually @command{gpgsm} tries to avoid dumping core by well written code and by
702 disabling core dumps for security reasons.  However, bugs are pretty
703 durable beasts and to squash them it is sometimes useful to have a core
704 dump.  This option enables core dumps unless the Bad Thing happened
705 before the option parsing.
706
707 @item --debug-no-chain-validation
708 @opindex debug-no-chain-validation
709 This is actually not a debugging option but only useful as such.  It
710 lets @command{gpgsm} bypass all certificate chain validation checks.
711
712 @item --debug-ignore-expiration
713 @opindex debug-ignore-expiration
714 This is actually not a debugging option but only useful as such.  It
715 lets @command{gpgsm} ignore all notAfter dates, this is used by the regression
716 tests.
717
718 @item --fixed-passphrase @var{string}
719 @opindex fixed-passphrase
720 Supply the passphrase @var{string} to the gpg-protect-tool.  This
721 option is only useful for the regression tests included with this
722 package and may be revised or removed at any time without notice.
723
724 @item --no-common-certs-import
725 @opindex no-common-certs-import
726 Suppress the import of common certificates on keybox creation.
727
728 @end table
729
730 All the long options may also be given in the configuration file after
731 stripping off the two leading dashes.
732
733 @c *******************************************
734 @c ***************            ****************
735 @c ***************  USER ID   ****************
736 @c ***************            ****************
737 @c *******************************************
738 @mansect how to specify a user id
739 @ifset isman
740 @include specify-user-id.texi
741 @end ifset
742
743 @c *******************************************
744 @c ***************            ****************
745 @c ***************   FILES    ****************
746 @c ***************            ****************
747 @c *******************************************
748 @mansect files
749 @node GPGSM Configuration
750 @section Configuration files
751
752 There are a few configuration files to control certain aspects of
753 @command{gpgsm}'s operation. Unless noted, they are expected in the
754 current home directory (@pxref{option --homedir}).
755
756 @table @file
757
758 @item gpgsm.conf
759 @cindex gpgsm.conf
760 This is the standard configuration file read by @command{gpgsm} on
761 startup.  It may contain any valid long option; the leading two dashes
762 may not be entered and the option may not be abbreviated.  This default
763 name may be changed on the command line (@pxref{option
764   --options}).  You should backup this file.
765
766
767 @item policies.txt
768 @cindex policies.txt
769 This is a list of allowed CA policies.  This file should list the
770 object identifiers of the policies line by line.  Empty lines and
771 lines starting with a hash mark are ignored.  Policies missing in this
772 file and not marked as critical in the certificate will print only a
773 warning; certificates with policies marked as critical and not listed
774 in this file will fail the signature verification.  You should backup
775 this file.
776
777 For example, to allow only the policy 2.289.9.9, the file should look
778 like this:
779
780 @c man:.RS
781 @example
782 # Allowed policies
783 2.289.9.9
784 @end example
785 @c man:.RE
786
787 @item qualified.txt
788 @cindex qualified.txt
789 This is the list of root certificates used for qualified certificates.
790 They are defined as certificates capable of creating legally binding
791 signatures in the same way as handwritten signatures are.  Comments
792 start with a hash mark and empty lines are ignored.  Lines do have a
793 length limit but this is not a serious limitation as the format of the
794 entries is fixed and checked by gpgsm: A non-comment line starts with
795 optional whitespace, followed by exactly 40 hex character, white space
796 and a lowercased 2 letter country code.  Additional data delimited with
797 by a white space is current ignored but might late be used for other
798 purposes.
799
800 Note that even if a certificate is listed in this file, this does not
801 mean that the certificate is trusted; in general the certificates listed
802 in this file need to be listed also in @file{trustlist.txt}.
803
804 This is a global file an installed in the data directory
805 (e.g. @file{/usr/share/gnupg/qualified.txt}).  GnuPG installs a suitable
806 file with root certificates as used in Germany.  As new Root-CA
807 certificates may be issued over time, these entries may need to be
808 updated; new distributions of this software should come with an updated
809 list but it is still the responsibility of the Administrator to check
810 that this list is correct.
811
812 Everytime @command{gpgsm} uses a certificate for signing or verification
813 this file will be consulted to check whether the certificate under
814 question has ultimately been issued by one of these CAs.  If this is the
815 case the user will be informed that the verified signature represents a
816 legally binding (``qualified'') signature.  When creating a signature
817 using such a certificate an extra prompt will be issued to let the user
818 confirm that such a legally binding signature shall really be created.
819
820 Because this software has not yet been approved for use with such
821 certificates, appropriate notices will be shown to indicate this fact.
822
823 @item help.txt
824 @cindex help.txt
825 This is plain text file with a few help entries used with
826 @command{pinentry} as well as a large list of help items for
827 @command{gpg} and @command{gpgsm}.  The standard file has English help
828 texts; to install localized versions use filenames like @file{help.LL.txt}
829 with LL denoting the locale.  GnuPG comes with a set of predefined help
830 files in the data directory (e.g. @file{/usr/share/gnupg/help.de.txt})
831 and allows overriding of any help item by help files stored in the
832 system configuration directory (e.g. @file{/etc/gnupg/help.de.txt}).
833 For a reference of the help file's syntax, please see the installed
834 @file{help.txt} file.
835
836
837 @item com-certs.pem
838 @cindex com-certs.pem
839 This file is a collection of common certificates used to populated a
840 newly created @file{pubring.kbx}.  An administrator may replace this
841 file with a custom one.  The format is a concatenation of PEM encoded
842 X.509 certificates.  This global file is installed in the data directory
843 (e.g. @file{/usr/share/gnupg/com-certs.pem}).
844
845 @end table
846
847 @c man:.RE
848 Note that on larger installations, it is useful to put predefined files
849 into the directory @file{/etc/skel/.gnupg/} so that newly created users
850 start up with a working configuration.  For existing users a small
851 helper script is provided to create these files (@pxref{addgnupghome}).
852
853 For internal purposes gpgsm creates and maintains a few other files;
854 they all live in in the current home directory (@pxref{option
855 --homedir}).  Only @command{gpgsm} may modify these files.
856
857
858 @table @file
859 @item pubring.kbx
860 @cindex pubring.kbx
861 This a database file storing the certificates as well as meta
862 information.  For debugging purposes the tool @command{kbxutil} may be
863 used to show the internal structure of this file.  You should backup
864 this file.
865
866 @item random_seed
867 @cindex random_seed
868 This content of this file is used to maintain the internal state of the
869 random number generator across invocations.  The same file is used by
870 other programs of this software too.
871
872 @item S.gpg-agent
873 @cindex S.gpg-agent
874 If this file exists and the environment variable @env{GPG_AGENT_INFO} is
875 not set, @command{gpgsm} will first try to connect to this socket for
876 accessing @command{gpg-agent} before starting a new @command{gpg-agent}
877 instance.  Under Windows this socket (which in reality be a plain file
878 describing a regular TCP listening port) is the standard way of
879 connecting the @command{gpg-agent}.
880
881 @end table
882
883
884 @c *******************************************
885 @c ***************            ****************
886 @c ***************  EXAMPLES  ****************
887 @c ***************            ****************
888 @c *******************************************
889 @mansect examples
890 @node GPGSM Examples
891 @section Examples
892
893 @example
894 $ gpgsm -er goo@@bar.net <plaintext >ciphertext
895 @end example
896
897
898 @c *******************************************
899 @c ***************              **************
900 @c ***************  UNATTENDED  **************
901 @c ***************              **************
902 @c *******************************************
903 @manpause
904 @node Unattended Usage
905 @section Unattended Usage
906
907 @command{gpgsm} is often used as a backend engine by other software.  To help
908 with this a machine interface has been defined to have an unambiguous
909 way to do this.  This is most likely used with the @code{--server} command
910 but may also be used in the standard operation mode by using the
911 @code{--status-fd} option.
912
913 @menu
914 * Automated signature checking::  Automated signature checking.
915 * CSR and certificate creation::  CSR and certificate creation.
916 @end menu
917
918 @node Automated signature checking,,,Unattended Usage
919 @section Automated signature checking
920
921 It is very important to understand the semantics used with signature
922 verification.  Checking a signature is not as simple as it may sound and
923 so the operation is a bit complicated.  In most cases it is required
924 to look at several status lines.  Here is a table of all cases a signed
925 message may have:
926
927 @table @asis
928 @item The signature is valid
929 This does mean that the signature has been successfully verified, the
930 certificates are all sane.  However there are two subcases with
931 important information:  One of the certificates may have expired or a
932 signature of a message itself as expired.  It is a sound practise to
933 consider such a signature still as valid but additional information
934 should be displayed.  Depending on the subcase @command{gpgsm} will issue
935 these status codes:
936   @table @asis
937   @item signature valid and nothing did expire
938   @code{GOODSIG}, @code{VALIDSIG}, @code{TRUST_FULLY}
939   @item signature valid but at least one certificate has expired
940   @code{EXPKEYSIG}, @code{VALIDSIG}, @code{TRUST_FULLY}
941   @item signature valid but expired
942   @code{EXPSIG}, @code{VALIDSIG}, @code{TRUST_FULLY}
943   Note, that this case is currently not implemented.
944   @end table
945
946 @item The signature is invalid
947 This means that the signature verification failed (this is an indication
948 of af a transfer error, a program error or tampering with the message).
949 @command{gpgsm} issues one of these status codes sequences:
950   @table @code
951   @item  @code{BADSIG}
952   @item  @code{GOODSIG}, @code{VALIDSIG} @code{TRUST_NEVER}
953   @end table
954
955 @item Error verifying a signature
956 For some reason the signature could not be verified, i.e. it cannot be
957 decided whether the signature is valid or invalid.  A common reason for
958 this is a missing certificate.
959
960 @end table
961
962 @node CSR and certificate creation,,,Unattended Usage
963 @section CSR and certificate creation
964
965 @ifclear gpgtwoone
966 @strong{Please notice}: The immediate creation of certificates is only
967 supported by GnuPG version 2.1 or later.  With a 2.0 version you may
968 only create a CSR.
969 @end ifclear
970
971 The command @option{--gen-key} may be used along with the option
972 @option{--batch} to either create a certificate signing request (CSR)
973 or an X.509 certificate. The is controlled by a parameter file; the
974 format of this file is as follows:
975
976 @itemize @bullet
977 @item Text only, line length is limited to about 1000 characters.
978 @item UTF-8 encoding must be used to specify non-ASCII characters.
979 @item Empty lines are ignored.
980 @item Leading and trailing while space is ignored.
981 @item A hash sign as the first non white space character indicates
982 a comment line.
983 @item Control statements are indicated by a leading percent sign, the
984 arguments are separated by white space from the keyword.
985 @item Parameters are specified by a keyword, followed by a colon.  Arguments
986 are separated by white space.
987 @item The first parameter must be @samp{Key-Type}, control statements
988 may be placed anywhere.
989 @item
990 The order of the parameters does not matter except for @samp{Key-Type}
991 which must be the first parameter.  The parameters are only used for
992 the generated CSR/certificate; parameters from previous sets are not
993 used.  Some syntactically checks may be performed.
994 @item
995 Key generation takes place when either the end of the parameter file
996 is reached, the next @samp{Key-Type} parameter is encountered or at the
997 control statement @samp{%commit} is encountered.
998 @end itemize
999
1000 @noindent
1001 Control statements:
1002
1003 @table @asis
1004
1005 @item %echo @var{text}
1006 Print @var{text} as diagnostic.
1007
1008 @item %dry-run
1009 Suppress actual key generation (useful for syntax checking).
1010
1011 @item %commit
1012 Perform the key generation.  Note that an implicit commit is done at
1013 the next @asis{Key-Type} parameter.
1014
1015 @c  %certfile <filename>
1016 @c      [Not yet implemented!]
1017 @c      Do not write the certificate to the keyDB but to <filename>.
1018 @c      This must be given before the first
1019 @c      commit to take place, duplicate specification of the same filename
1020 @c      is ignored, the last filename before a commit is used.
1021 @c      The filename is used until a new filename is used (at commit points)
1022 @c      and all keys are written to that file.  If a new filename is given,
1023 @c      this file is created (and overwrites an existing one).
1024 @c      Both control statements must be given.
1025 @end table
1026
1027 @noindent
1028 General Parameters:
1029
1030 @table @asis
1031
1032 @item Key-Type: @var{algo}
1033 Starts a new parameter block by giving the type of the primary
1034 key. The algorithm must be capable of signing.  This is a required
1035 parameter.  The only supported value for @var{algo} is @samp{rsa}.
1036
1037 @item Key-Length: @var{nbits}
1038 The requested length of a generated key in bits.  Defaults to 2048.
1039
1040 @item Key-Grip: @var{hexstring}
1041 This is optional and used to generate a CSR or certificatet for an
1042 already existing key.  Key-Length will be ignored when given.
1043
1044 @item Key-Usage: @var{usage-list}
1045 Space or comma delimited list of key usage, allowed values are
1046 @samp{encrypt}, @samp{sign} and @samp{cert}.  This is used to generate
1047 the keyUsage extension.  Please make sure that the algorithm is
1048 capable of this usage.  Default is to allow encrypt and sign.
1049
1050 @item Name-DN: @var{subject-name}
1051 This is the Distinguished Name (DN) of the subject in RFC-2253 format.
1052
1053 @item Name-Email: @var{string}
1054 This is an email address for the altSubjectName.  This parameter is
1055 optional but may occur several times to add several email addresses to
1056 a certificate.
1057
1058 @item Name-DNS: @var{string}
1059 The is an DNS name for the altSubjectName.  This parameter is optional
1060 but may occur several times to add several DNS names to a certificate.
1061
1062 @item Name-URI: @var{string}
1063 This is an URI for the altSubjectName.  This parameter is optional but
1064 may occur several times to add several URIs to a certificate.
1065 @end table
1066
1067 @noindent
1068 Additional parameters used to create a certificate (in contrast to a
1069 certificate signing request):
1070
1071 @table @asis
1072
1073 @item Serial: @var{sn}
1074 If this parameter is given an X.509 certificate will be generated.
1075 @var{sn} is expected to be a hex string representing an unsigned
1076 integer of arbitary length.  The special value @samp{random} can be
1077 used to create a 64 bit random serial number.
1078
1079 @item Issuer-DN: @var{issuer-name}
1080 This is the DN name of the issuer in rfc2253 format.  If it is not set
1081 it will default to the subject DN and a special GnuPG extension will
1082 be included in the certificate to mark it as a standalone certificate.
1083
1084 @item Creation-Date: @var{iso-date}
1085 @itemx Not-Before: @var{iso-date}
1086 Set the notBefore date of the certificate.  Either a date like
1087 @samp{1986-04-26} or @samp{1986-04-26 12:00} or a standard ISO
1088 timestamp like @samp{19860426T042640} may be used.  The time is
1089 considered to be UTC.  If it is not given the current date is used.
1090
1091 @item Expire-Date: @var{iso-date}
1092 @itemx Not-After: @var{iso-date}
1093 Set the notAfter date of the certificate.  Either a date like
1094 @samp{2063-04-05} or @samp{2063-04-05 17:00} or a standard ISO
1095 timestamp like @samp{20630405T170000} may be used.  The time is
1096 considered to be UTC.  If it is not given a default value in the not
1097 too far future is used.
1098
1099 @item Signing-Key: @var{keygrip}
1100 This gives the keygrip of the key used to sign the certificate.  If it
1101 is not given a self-signed certificate will be created.  For
1102 compatibility with future versions, it is suggested to prefix the
1103 keygrip with a @samp{&}.
1104
1105 @item Hash-Algo: @var{hash-algo}
1106 Use @var{hash-algo} for this CSR or certificate.  The supported hash
1107 algorithms are: @samp{sha1}, @samp{sha256}, @samp{sha384} and
1108 @samp{sha512}; they may also be specified with uppercase letters.  The
1109 default is @samp{sha1}.
1110
1111 @end table
1112
1113 @c *******************************************
1114 @c ***************           *****************
1115 @c ***************  ASSSUAN  *****************
1116 @c ***************           *****************
1117 @c *******************************************
1118 @node GPGSM Protocol
1119 @section The Protocol the Server Mode Uses.
1120
1121 Description of the protocol used to access @command{GPGSM}.
1122 @command{GPGSM} does implement the Assuan protocol and in addition
1123 provides a regular command line interface which exhibits a full client
1124 to this protocol (but uses internal linking).  To start
1125 @command{gpgsm} as a server the command line the option
1126 @code{--server} must be used.  Additional options are provided to
1127 select the communication method (i.e. the name of the socket).
1128
1129 We assume that the connection has already been established; see the
1130 Assuan manual for details.
1131
1132 @menu
1133 * GPGSM ENCRYPT::         Encrypting a message.
1134 * GPGSM DECRYPT::         Decrypting a message.
1135 * GPGSM SIGN::            Signing a message.
1136 * GPGSM VERIFY::          Verifying a message.
1137 * GPGSM GENKEY::          Generating a key.
1138 * GPGSM LISTKEYS::        List available keys.
1139 * GPGSM EXPORT::          Export certificates.
1140 * GPGSM IMPORT::          Import certificates.
1141 * GPGSM DELETE::          Delete certificates.
1142 * GPGSM GETINFO::         Information about the process
1143 @end menu
1144
1145
1146 @node GPGSM ENCRYPT
1147 @subsection Encrypting a Message
1148
1149 Before encryption can be done the recipient must be set using the
1150 command:
1151
1152 @example
1153   RECIPIENT @var{userID}
1154 @end example
1155
1156 Set the recipient for the encryption.  @var{userID} should be the
1157 internal representation of the key; the server may accept any other way
1158 of specification.  If this is a valid and trusted recipient the server
1159 does respond with OK, otherwise the return is an ERR with the reason why
1160 the recipient cannot be used, the encryption will then not be done for
1161 this recipient.  If the policy is not to encrypt at all if not all
1162 recipients are valid, the client has to take care of this.  All
1163 @code{RECIPIENT} commands are cumulative until a @code{RESET} or an
1164 successful @code{ENCRYPT} command.
1165
1166 @example
1167   INPUT FD[=@var{n}] [--armor|--base64|--binary]
1168 @end example
1169
1170 Set the file descriptor for the message to be encrypted to @var{n}.
1171 Obviously the pipe must be open at that point, the server establishes
1172 its own end.  If the server returns an error the client should consider
1173 this session failed.  If @var{n} is not given, this commands uses the
1174 last file descriptor passed to the application.
1175 @xref{fun-assuan_sendfd, ,the assuan_sendfd function,assuan,the Libassuan
1176 manual}, on how to do descriptor passing.
1177
1178 The @code{--armor} option may be used to advice the server that the
1179 input data is in @acronym{PEM} format, @code{--base64} advices that a
1180 raw base-64 encoding is used, @code{--binary} advices of raw binary
1181 input (@acronym{BER}).  If none of these options is used, the server
1182 tries to figure out the used encoding, but this may not always be
1183 correct.
1184
1185 @example
1186   OUTPUT FD[=@var{n}] [--armor|--base64]
1187 @end example
1188
1189 Set the file descriptor to be used for the output (i.e. the encrypted
1190 message). Obviously the pipe must be open at that point, the server
1191 establishes its own end.  If the server returns an error he client
1192 should consider this session failed.
1193
1194 The option armor encodes the output in @acronym{PEM} format, the
1195 @code{--base64} option applies just a base 64 encoding.  No option
1196 creates binary output (@acronym{BER}).
1197
1198 The actual encryption is done using the command
1199
1200 @example
1201   ENCRYPT
1202 @end example
1203
1204 It takes the plaintext from the @code{INPUT} command, writes to the
1205 ciphertext to the file descriptor set with the @code{OUTPUT} command,
1206 take the recipients from all the recipients set so far.  If this command
1207 fails the clients should try to delete all output currently done or
1208 otherwise mark it as invalid.  @command{GPGSM} does ensure that there
1209 will not be any
1210 security problem with leftover data on the output in this case.
1211
1212 This command should in general not fail, as all necessary checks have
1213 been done while setting the recipients.  The input and output pipes are
1214 closed.
1215
1216
1217 @node GPGSM DECRYPT
1218 @subsection Decrypting a message
1219
1220 Input and output FDs are set the same way as in encryption, but
1221 @code{INPUT} refers to the ciphertext and output to the plaintext. There
1222 is no need to set recipients.  @command{GPGSM} automatically strips any
1223 @acronym{S/MIME} headers from the input, so it is valid to pass an
1224 entire MIME part to the INPUT pipe.
1225
1226 The encryption is done by using the command
1227
1228 @example
1229   DECRYPT
1230 @end example
1231
1232 It performs the decrypt operation after doing some check on the internal
1233 state. (e.g. that all needed data has been set).  Because it utilizes
1234 the GPG-Agent for the session key decryption, there is no need to ask
1235 the client for a protecting passphrase - GpgAgent takes care of this by
1236 requesting this from the user.
1237
1238
1239 @node GPGSM SIGN
1240 @subsection Signing a Message
1241
1242 Signing is usually done with these commands:
1243
1244 @example
1245   INPUT FD[=@var{n}] [--armor|--base64|--binary]
1246 @end example
1247
1248 This tells @command{GPGSM} to read the data to sign from file descriptor @var{n}.
1249
1250 @example
1251   OUTPUT FD[=@var{m}] [--armor|--base64]
1252 @end example
1253
1254 Write the output to file descriptor @var{m}.  If a detached signature is
1255 requested, only the signature is written.
1256
1257 @example
1258   SIGN [--detached]
1259 @end example
1260
1261 Sign the data set with the INPUT command and write it to the sink set by
1262 OUTPUT.  With @code{--detached}, a detached signature is created
1263 (surprise).
1264
1265 The key used for signing is the default one or the one specified in
1266 the configuration file.  To get finer control over the keys, it is
1267 possible to use the command
1268
1269 @example
1270   SIGNER @var{userID}
1271 @end example
1272
1273 to the signer's key.  @var{userID} should be the
1274 internal representation of the key; the server may accept any other way
1275 of specification.  If this is a valid and trusted recipient the server
1276 does respond with OK, otherwise the return is an ERR with the reason why
1277 the key cannot be used, the signature will then not be created using
1278 this key.  If the policy is not to sign at all if not all
1279 keys are valid, the client has to take care of this.  All
1280 @code{SIGNER} commands are cumulative until a @code{RESET} is done.
1281 Note that a @code{SIGN} does not reset this list of signers which is in
1282 contrats to the @code{RECIPIENT} command.
1283
1284
1285 @node GPGSM VERIFY
1286 @subsection Verifying a Message
1287
1288 To verify a mesage the command:
1289
1290 @example
1291   VERIFY
1292 @end example
1293
1294 is used. It does a verify operation on the message send to the input FD.
1295 The result is written out using status lines.  If an output FD was
1296 given, the signed text will be written to that.  If the signature is a
1297 detached one, the server will inquire about the signed material and the
1298 client must provide it.
1299
1300 @node GPGSM GENKEY
1301 @subsection Generating a Key
1302
1303 This is used to generate a new keypair, store the secret part in the
1304 @acronym{PSE} and the public key in the key database.  We will probably
1305 add optional commands to allow the client to select whether a hardware
1306 token is used to store the key.  Configuration options to
1307 @command{GPGSM} can be used to restrict the use of this command.
1308
1309 @example
1310   GENKEY
1311 @end example
1312
1313 @command{GPGSM} checks whether this command is allowed and then does an
1314 INQUIRY to get the key parameters, the client should then send the
1315 key parameters in the native format:
1316
1317 @example
1318     S: INQUIRE KEY_PARAM native
1319     C: D foo:fgfgfg
1320     C: D bar
1321     C: END
1322 @end example
1323
1324 Please note that the server may send Status info lines while reading the
1325 data lines from the client.  After this the key generation takes place
1326 and the server eventually does send an ERR or OK response.  Status lines
1327 may be issued as a progress indicator.
1328
1329
1330 @node GPGSM LISTKEYS
1331 @subsection List available keys
1332
1333 To list the keys in the internal database or using an external key
1334 provider, the command:
1335
1336 @example
1337   LISTKEYS  @var{pattern}
1338 @end example
1339
1340 is used.  To allow multiple patterns (which are ORed during the search)
1341 quoting is required: Spaces are to be translated into "+" or into "%20";
1342 in turn this requires that the usual escape quoting rules are done.
1343
1344 @example
1345   LISTSECRETKEYS @var{pattern}
1346 @end example
1347
1348 Lists only the keys where a secret key is available.
1349
1350 The list commands  commands are affected by the option
1351
1352 @example
1353   OPTION list-mode=@var{mode}
1354 @end example
1355
1356 where mode may be:
1357 @table @code
1358 @item 0
1359 Use default (which is usually the same as 1).
1360 @item 1
1361 List only the internal keys.
1362 @item 2
1363 List only the external keys.
1364 @item 3
1365 List internal and external keys.
1366 @end table
1367
1368 Note that options are valid for the entire session.
1369
1370
1371 @node GPGSM EXPORT
1372 @subsection Export certificates
1373
1374 To export certificate from the internal key database the command:
1375
1376 @example
1377   EXPORT [--data [--armor] [--base64]] [--] @var{pattern}
1378 @end example
1379
1380 is used.  To allow multiple patterns (which are ORed) quoting is
1381 required: Spaces are to be translated into "+" or into "%20"; in turn
1382 this requires that the usual escape quoting rules are done.
1383
1384 If the @option{--data} option has not been given, the format of the
1385 output depends on what was set with the OUTPUT command.  When using
1386 @acronym{PEM} encoding a few informational lines are prepended.
1387
1388 If the @option{--data} has been given, a target set via OUTPUT is
1389 ignored and the data is returned inline using standard
1390 @code{D}-lines. This avoids the need for an extra file descriptor.  In
1391 this case the options @option{--armor} and @option{--base64} may be used
1392 in the same way as with the OUTPUT command.
1393
1394
1395 @node GPGSM IMPORT
1396 @subsection Import certificates
1397
1398 To import certificates into the internal key database, the command
1399
1400 @example
1401   IMPORT [--re-import]
1402 @end example
1403
1404 is used.  The data is expected on the file descriptor set with the
1405 @code{INPUT} command.  Certain checks are performed on the
1406 certificate.  Note that the code will also handle PKCS#12 files and
1407 import private keys; a helper program is used for that.
1408
1409 With the option @option{--re-import} the input data is expected to a be
1410 a linefeed separated list of fingerprints.  The command will re-import
1411 the corresponding certificates; that is they are made permanent by
1412 removing their ephemeral flag.
1413
1414
1415 @node GPGSM DELETE
1416 @subsection Delete certificates
1417
1418 To delete a certificate the command
1419
1420 @example
1421   DELKEYS @var{pattern}
1422 @end example
1423
1424 is used.  To allow multiple patterns (which are ORed) quoting is
1425 required: Spaces are to be translated into "+" or into "%20"; in turn
1426 this requires that the usual escape quoting rules are done.
1427
1428 The certificates must be specified unambiguously otherwise an error is
1429 returned.
1430
1431 @node GPGSM GETINFO
1432 @subsection  Return information about the process
1433
1434 This is a multipurpose function to return a variety of information.
1435
1436 @example
1437 GETINFO @var{what}
1438 @end example
1439
1440 The value of @var{what} specifies the kind of information returned:
1441 @table @code
1442 @item version
1443 Return the version of the program.
1444 @item pid
1445 Return the process id of the process.
1446 @item agent-check
1447 Return success if the agent is running.
1448 @item cmd_has_option @var{cmd} @var{opt}
1449 Return success if the command @var{cmd} implements the option @var{opt}.
1450 The leading two dashes usually used with @var{opt} shall not be given.
1451 @end table
1452
1453 @mansect see also
1454 @ifset isman
1455 @command{gpg2}(1),
1456 @command{gpg-agent}(1)
1457 @end ifset
1458 @include see-also-note.texi