GPGSM Man Inst
GPGSM Man Inst
GPGSM Man Inst
ssed verbatim to this command; use aq--helpaq to get a list of supported operati
ons.
How to manage the certificates and keys
--gen-key
This command allows the creation of a certificate signing request. It is com
monly used along with the --output option to save the created CSR into a file. I
f used with the --batch a parameter file is used to create the CSR.
--list-keys
-k
List all available certificates stored in the local key database. Note that
the displayed data might be reformatted for better human readability and illegal
characters are replaced by safe substitutes.
--list-secret-keys
-K
List all available certificates for which a corresponding a secret key is av
ailable.
--list-external-keys pattern
List certificates matching pattern using an external server. This utilizes t
he dirmngr service.
--list-chain
Same as --list-keys but also prints all keys making up the chain.
--dump-cert
--dump-keys
List all available certificates stored in the local key database using a for
mat useful mainly for debugging.
--dump-chain
Same as --dump-keys but also prints all keys making up the chain.
--dump-secret-keys
List all available certificates for which a corresponding a secret key is av
ailable using a format useful mainly for debugging.
--dump-external-keys pattern
List certificates matching pattern using an external server. This utilizes t
he dirmngr service. It uses a format useful mainly for debugging.
--keydb-clear-some-cert-flags
This is a debugging aid to reset certain flags in the key database which are
used to cache certain certificate stati. It is especially useful if a bad CRL o
r a weird running OCSP responder did accidentally revoke certificate. There is n
o security issue with this command because gpgsm always make sure that the valid
ity of a certificate is checked right before it is used.
--delete-keys pattern
Delete the keys matching pattern. Note that there is no command to delete th
e secret part of the key directly. In case you need to do this, you should run t
he command gpgsm --dump-secret-keys KEYID before you delete the key, copy the st
ring of hex-digits in the ''keygrip'' line and delete the file consisting of the
se hex-digits and the suffix .key from the oqprivate-keys-v1.dcq directory below
our GnuPG home directory (usually oq~/.gnupgcq).
--export [pattern]
Export all certificates stored in the Keybox or those specified by the optio
nal pattern. Those pattern consist of a list of user ids (see: [how-to-specify-a
-user-id]). When used along with the --armor option a few informational lines ar
e prepended before each block. There is one limitation: As there is no commonly
agreed upon way to pack more than one certificate into an ASN.1 structure, the b
inary export (i.e. without using armor) works only for the export of one certifi
cate. Thus it is required to specify a pattern which yields exactly one certific
ate. Ephemeral certificate are only exported if all pattern are given as fingerp
rints or keygrips.
--export-secret-key-p12 key-id
Export the private key and the certificate identified by key-id in a PKCS#12
format. When using along with the --armor option a few informational lines are
prepended to the output. Note, that the PKCS#12 format is not very secure and th
is command is only provided if there is no other way to exchange the private key
. (see: [option --p12-charset])
--import [files]
Import the certificates from the PEM or binary encoded files as well as from
signed-only messages. This command may also be used to import a secret key from
a PKCS#12 file.
--learn-card
Read information about the private keys from the smartcard and import the ce
rtificates from there. This command utilizes the gpg-agent and in turn the scdae
mon.
--passwd user_id
Change the passphrase of the private key belonging to the certificate specif
ied as user_id. Note, that changing the passphrase/PIN of a smartcard is not yet
supported.
Options
GPGSM comes features a bunch of options to control the exact behaviour and to ch
ange the default configuration.
How to change the configuration
These options are used to change the configuration and are usually found in the
option file.
--options file
Reads configuration from file instead of from the default per-user configura
tion file. The default configuration file is named oqgpgsm.confcq and expected i
n the oq.gnupgcq directory directly below the home directory of the user.
--homedir dir
Set the name of the home directory to dir. If this option is not used, the h
ome directory defaults to oq~/.gnupgcq. It is only recognized when given on the
command line. It also overrides any home directory stated through the environmen
t variable oqGNUPGHOMEcq or (on W32 systems) by means of the Registry entry HKCU
\Software\GNU\GnuPG:HomeDir.
-v
--verbose
Outputs additional information while running. You can increase the verbosity
by giving several verbose commands to gpgsm, such as aq-vvaq.
--policy-file filename
Change the default name of the policy file to filename.
--agent-program file
Specify an agent program to be used for secret key operations. The default v
alue is the oq/usr/local/bin/gpg-agentcq. This is only used as a fallback when t
he environment variable GPG_AGENT_INFO is not set or a running agent can't be co
nnected.
--dirmngr-program file
Specify a dirmngr program to be used for CRL checks. The default value is oq
/usr/sbin/dirmngrcq. This is only used as a fallback when the environment variab
le DIRMNGR_INFO is not set or a running dirmngr can't be connected.
--prefer-system-dirmngr
If a system wide dirmngr is running in daemon mode, first try to connect to
this one. Fallback to a pipe based server if this does not work. Under Windows t
his option is ignored because the system dirmngr is always used.
--disable-dirmngr
Entirely disable the use of the Dirmngr.
--no-secmem-warning
Don't print a warning when the so called "secure memory" can't be used.
--log-file file
all certs, 0 does not include any certs, 1 includes only the signers cert (this
is the default) and all other positive values include up to n certificates star
ting with the signer cert. The default is -2.
--cipher-algo oid
Use the cipher algorithm with the ASN.1 object identifier oid for encryption
. For convenience the strings 3DES, AES and AES256 may be used instead of their
OIDs. The default is 3DES (1.2.840.113549.3.7).
--digest-algo name
Use name as the message digest algorithm. Usually this algorithm is deduced
from the respective signing certificate. This option forces the use of the given
algorithm and may lead to severe interoperability problems.
Doing things one usually don't want to do.
--extra-digest-algo name
Sometimes signatures are broken in that they announce a different digest alg
orithm than actually used. gpgsm uses a one-pass data processing model and thus
needs to rely on the announced digest algorithms to properly hash the data. As a
workaround this option may be used to tell gpg to also hash the data using the
algorithm name; this slows processing down a little bit but allows to verify suc
h broken signatures. If gpgsm prints an error like ''digest algo 8 has not been
enabled'' you may want to try this option, with aqSHA256aq for name.
--faked-system-time epoch
This option is only useful for testing; it sets the system time back or fort
h to epoch which is the number of seconds elapsed since the year 1970. Alternati
vely epoch may be given as a full ISO time string (e.g. "20070924T154812").
--with-ephemeral-keys
Include ephemeral flagged keys in the output of key listings. Note that they
are included anyway if the key specification for a listing is given as fingerpr
int or keygrip.
--debug-level level
Select the debug level for investigating problems. level may be a numeric va
lue or by a keyword:
none
No debugging at all. A value of less than 1 may be used instead of the keywo
rd.
basic
Some basic debug messages. A value between 1 and 2 may be used instead of th
e keyword.
advanced
More verbose debug messages. A value between 3 and 5 may be used instead of
the keyword.
expert
Even more detailed messages. A value between 6 and 8 may be used instead of
the keyword.
guru
All of the debug messages you can get. A value greater than 8 may be used in
stead of the keyword. The creation of hash tracing files is only enabled if the
keyword is used.
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 sele
cted to best aid in debugging.
--debug flags
This option is only useful for debugging and the behaviour may change at any
time without notice; using --debug-levels is the preferred method to select the
debug verbosity. FLAGS are bit encoded and may be given in usual C-Syntax. The
currently defined bits are:
0 (1)
on --with-colons.
234567C4
0F34E556E
01347A56A
0xAB123456
234AABBCC34567C4
0F323456784E56EAB
01AB3FED1347A5612
0x234AABBCC34567C4
By fingerprint.
This format is deduced from the length of the string and its content or the
0x prefix. Note, that only the 20 byte version fingerprint is available with gpg
sm (i.e. the SHA-1 hash of the certificate).
When using gpg an exclamation mark (!) may be appended to force using the sp
ecified primary or secondary key and not to try and calculate which primary or s
econdary key to use.
The best way to specify a key Id is by using the fingerprint. This avoids an
y ambiguities in case that there are duplicated key IDs.
1234343434343434C434343434343434
123434343434343C3434343434343734349A3434
0E12343434343434343434EAB3484343434343434
0xE12343434343434343434EAB3484343434343434
(gpgsm also accepts colons between each pair of hexadecimal digits because this
is the de-facto standard on how to present X.509 fingerprints.)
By exact match on OpenPGP user ID.
This is denoted by a leading equal sign. It does not make sense for X.509 ce
rtificates.
=Heinrich Heine <[email protected]>
By exact match on an email address.
This is indicated by enclosing the email address in the usual way with left
and right angles.
<[email protected]>
By word match.
All words must match exactly (not case sensitive) but can appear in any orde
r in the user ID or a subjects name. Words are any sequences of letters, digits,
the underscore and all characters with bit 7 set.
+Heinrich Heine duesseldorf
By exact match on the subject's DN.
This is indicated by a leading slash, directly followed by the RFC-2253 enco
ded DN of the subject. Note that you can't use the string printed by "gpgsm --li
st-keys" because that one as been reordered and modified for better readability;
use --with-colons to print the raw (but standard escaped) RFC-2253 string
/CN=Heinrich Heine,O=Poets,L=Paris,C=FR
By exact match on the issuer's DN.
This is indicated by a leading hash mark, directly followed by a slash and t
hen directly followed by the rfc2253 encoded DN of the issuer. This should retur
n the Root cert of the issuer. See note above.
#/CN=Root Cert,O=Poets,L=Paris,C=FR
By exact match on serial number and issuer's DN.
This is indicated by a hash mark, followed by the hexadecimal representation
of the serial number, then followed by a slash and the RFC-2253 encoded DN of t
he issuer. See note above.
#4F03/CN=Root Cert,O=Poets,L=Paris,C=FR
By keygrip
This is indicated by an ampersand followed by the 40 hex digits of a keygrip
. gpgsm prints the keygrip when using the command --dump-cert. It does not yet w
ork for OpenPGP keys.
&D75F22C3F86E355877348498CDC92BD21010A480
By substring match.
This is the default mode but applications may want to explicitly indicate th
is by putting the asterisk in front. Match is not case sensitive.
Heine
*Heine
Please note that we have reused the hash mark identifier which was used in old G
nuPG versions to indicate the so called local-id. It is not anymore used and the
re should be no conflict when used with X.509 stuff.
Using the RFC-2253 format of DNs has the drawback that it is not possible to map
them back to the original encoding, however we don't have to do this because ou
r key database stores this encoding as meta data.
Examples
$ gpgsm -er [email protected] <plaintext >ciphertext
gpgsm is often used as a backend engine by other software. To help with this a m
achine interface has been defined to have an unambiguous way to do this. This is
most likely used with the --server command but may also be used in the standard
operation mode by using the --status-fd option.
It is very important to understand the semantics used with signature verificatio
n. Checking a signature is not as simple as it may sound and so the operation is
a bit complicated. In most cases it is required to look at several status lines
. Here is a table of all cases a signed message may have:
The signature is valid
This does mean that the signature has been successfully verified, the certif
icates are all sane. However there are two subcases with important information:
One of the certificates may have expired or a signature of a message itself as e
xpired. It is a sound practise to consider such a signature still as valid but a
dditional information should be displayed. Depending on the subcase gpgsm will i
ssue these status codes: .RS
.TP
signature valid and nothing did expire GOODSIG, VALIDSIG, TRUST_FULLY
.TP
signature valid but at least one certificate has expired EXPKEYSIG, VALIDSIG
, TRUST_FULLY
.TP
Everytime gpgsm uses a certificate for signing or verification this file wil
l be consulted to check whether the certificate under question has ultimately be
en issued by one of these CAs. If this is the case the user will be informed tha
t the verified signature represents a legally binding (''qualified'') signature.
When creating a signature using such a certificate an extra prompt will be issu
ed to let the user confirm that such a legally binding signature shall really be
created.
Because this software has not yet been approved for use with such certificat
es, appropriate notices will be shown to indicate this fact.
help.txt
This is plain text file with a few help entries used with pinentry as well a
s a large list of help items for gpg and gpgsm. The standard file has English he
lp texts; to install localized versions use filenames like oqhelp.LL.txtcq with
LL denoting the locale. GnuPG comes with a set of predefined help files in the d
ata directory (e.g. oq/usr/share/gnupg/help.de.txtcq) and allows overriding of a
ny help item by help files stored in the system configuration directory (e.g. oq
/etc/gnupg/help.de.txtcq). For a reference of the help file's syntax, please see
the installed oqhelp.txtcq file.
com-certs.pem
This file is a collection of common certificates used to populated a newly c
reated oqpubring.kbxcq. An administrator may replace this file with a custom one
. The format is a concatenation of PEM encoded X.509 certificates. This global f
ile is installed in the data directory (e.g. oq/usr/share/gnupg/qualified.txtcq)
.
Note that on larger installations, it is useful to put predefined files into the
directory oq/etc/skel/.gnupg/cq so that newly created users start up with a wor
king configuration. For existing users a small helper script is provided to crea
te these files (see: [addgnupghome]).
For internal purposes gpgsm creates and maintains a few other files; they all li
ve in in the current home directory (see: [option --homedir]). Only gpgsm may mo
dify these files.
pubring.kbx
This a database file storing the certificates as well as meta information. F
or debugging purposes the tool kbxutil may be used to show the internal structur
e of this file. You should backup this file.
random_seed
This content of this file is used to maintain the internal state of the rand
om number generator across invocations. The same file is used by other programs
of this software too.
S.gpg-agent
If this file exists and the environment variable oqGPG_AGENT_INFOcq is not s
et, gpgsm will first try to connect to this socket for accessing gpg-agent befor
e starting a new gpg-agent instance. Under Windows this socket (which in reality
be a plain file describing a regular TCP listening port) is the standard way of
connecting the gpg-agent.
See Also