GPGSM(1)
GPGSM(1) โ CMS encryption and signing tool ๐
GNU Privacy Guard 2.4 โจ
NAME ๐
gpgsm โ CMS encryption and signing tool
SYNOPSIS ๐ฆ
gpgsm [--homedir dir] [--options file] [options] command [args]
DESCRIPTION ๐
Okay so bestie, gpgsm is basically the sibling of gpg that handles digital encryption and signing on X.509 certificates and the CMS protocol. It's mainly used as a backend for S/MIME mail processing. It also has full-featured certificate management and follows all the rules defined for the German Sphinx project. Slay. ๐
COMMANDS โจ
Commands are not distinguished from options, except for the one little detail that only one command is allowed.
Commands not specific to the function ๐ซถ
--versionโ Print the program version and licensing information. Heads up: you cannot abbreviate this command.--help,-hโ Print a usage message summarizing the most useful command-line options. Heads up: you cannot abbreviate this command.--warrantyโ Print warranty information. Heads up: you cannot abbreviate this command.--dump-optionsโ Print a list of all available options and commands. Heads up: you cannot abbreviate this command.
Commands to select the type of operation ๐ฅ
--encryptโ Perform an encryption. The keys the data is encrypted to must be set using the option--recipient.--decryptโ Perform a decryption; the type of input is automatically determined. It may either be in binary form or PEM encoded; automatic determination of base-64 encoding is not done.--signโ Create a digital signature. The key used is either the first one found in the keybox or those set with the--local-useroption.--verifyโ Check a signature file for validity. Depending on the arguments, a detached signature may also be checked.--serverโ Run in server mode and wait for commands on the stdin.--call-dirmngr command [args]โ Behave as a Dirmngr client issuing the requestcommandwith the optional list ofargs. The output of the Dirmngr is printed to stdout. Please note that file names given as arguments should have an absolute file name (i.e. commencing with/) because they are passed verbatim to the Dirmngr and the working directory of the Dirmngr might not be the same as the one of this client. Currently it is not possible to pass data via stdin to the Dirmngr.commandshould not contain spaces.
This command is required for certain maintaining tasks of the dirmngr where a dirmngr must be able to call back to gpgsm. See the Dirmngr manual for details.
--call-protect-tool argumentsโ Certain maintenance operations are done by an external program calledgpg-protect-tool; this is usually not installed in a directory listed in thePATHvariable. This command provides a simple wrapper to access this tool.argumentsare passed verbatim to this command; use--helpto get a list of supported operations.
How to manage the certificates and keys ๐
--generate-key,--gen-keyโ This command allows the creation of a certificate signing request or a self-signed certificate. It is commonly used along with the--outputoption to save the created CSR or certificate into a file. If used with--batch, a parameter file is used to create the CSR or certificate and it is further possible to create non-self-signed certificates.--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 secret key is available.--list-external-keys patternโ List certificates matchingpatternusing an external server. This utilizes the dirmngr service.--list-chainโ Same as--list-keysbut also prints all keys making up the chain.--dump-cert,--dump-keysโ List all available certificates stored in the local key database using a format useful mainly for debugging.--dump-chainโ Same as--dump-keysbut also prints all keys making up the chain.--dump-secret-keysโ List all available certificates for which a corresponding secret key is available using a format useful mainly for debugging.--dump-external-keys patternโ List certificates matchingpatternusing an external server. This utilizes the dirmngr service. It uses a format useful mainly for debugging.--show-certs [files]โ This command takes certificate files as input and prints information about them in the same format as--dump-certdoes. Each file may either contain a single binary certificate or several PEM encoded certificates. If no files are given, the input is taken from stdin.
Please note that the listing format may be changed in future releases and that the option --with-colons has currently no effect.
--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 statuses. It is especially useful if a bad CRL or a weird running OCSP responder did accidentally revoke a certificate. There is no security issue with this command becausegpgsmalways makes sure that the validity of a certificate is checked right before it is used.--delete-keys patternโ Delete the keys matchingpattern. Note that there is no command to delete the secret part of the key directly. In case you need to do this, you should run the commandgpgsm --dump-secret-keys KEYIDbefore you delete the key, copy the string of hex-digits in thekeygripline and delete the file consisting of these hex-digits and the suffix.keyfrom theprivate-keys-v1.ddirectory below our GnuPG home directory (usually~/.gnupg).--export [pattern]โ Export all certificates stored in the Keybox or those specified by the optionalpattern. Those patterns consist of a list of user ids (see: [how-to-specify-a-user-id]). When used along with the--armoroption a few informational lines are 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 binary export (i.e. without using armor) works only for the export of one certificate. Thus it is required to specify a pattern which yields exactly one certificate. Ephemeral certificates are only exported if all patterns are given as fingerprints or keygrips.--export-secret-key-p12 key-idโ Export the private key and the certificate identified bykey-idusing the PKCS#12 format. When used with the--armoroption a few informational lines are prepended to the output. Note that the PKCS#12 format is not very secure and proper transport security should be used to convey the exported key. (See: [option --p12-charset].)--export-secret-key-p8 key-id,--export-secret-key-raw key-idโ Export the private key of the certificate identified bykey-idwith any encryption stripped. The...-rawcommand exports in PKCS#1 format; the...-p8command exports in PKCS#8 format. When used with the--armoroption a few informational lines are prepended to the output. These commands are useful to prepare a key for use on a TLS server.--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 certificates from there. This command utilizes thegpg-agentand in turn thescdaemon.--change-passphrase user_id,--passwd user_idโ Change the passphrase of the private key belonging to the certificate specified asuser_id. Note that changing the passphrase/PIN of a smartcard is not yet supported.
OPTIONS ๐
GPGSM features a bunch of options to control the exact behaviour and to change 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 fromfileinstead of from the default per-user configuration file. The default configuration file is namedgpgsm.confand expected in the.gnupgdirectory directly below the home directory of the user.--homedir dirโ Set the name of the home directory todir. If this option is not used, the home directory defaults to~/.gnupg. It is only recognized when given on the command line. It also overrides any home directory stated through the environment variableGNUPGHOMEor (on Windows systems) by means of the Registry entryHKCU\Software\GNU\GnuPG:HomeDir.
On Windows systems it is possible to install GnuPG as a portable application. In this case only this command line option is considered, all other ways to set a home directory are ignored.
-v,--verboseโ Outputs additional information while running. You can increase the verbosity by giving several verbose commands togpgsm, such as-vv.--keyserver stringโ This is a deprecated option. It was used to add an LDAP server to use for X.509 certificate and CRL lookup. The alias--ldapserverexisted from version 2.2.28 to 2.2.33 and 2.3.2 to 2.3.4 but is now entirely ignored.
LDAP servers must be given in the configuration for dirmngr.
--policy-file filenameโ Change the default name of the policy file tofilename. The default name ispolicies.txt.--agent-program fileโ Specify an agent program to be used for secret key operations. The default value is determined by running the commandgpgconf. Note that the pipe symbol (|) is used for a regression test suite hack and may thus not be used in the file name.--dirmngr-program fileโ tells gpgsm which dirmngr binary to hit up for CRL checks. The default isโ/usr/bin/dirmngrโ, bestie, so only touch this if yours lives somewhere else ๐--prefer-system-dirmngrโ this one's obsolete and gets ignored. It's giving "old fling you still have in your contacts" ๐ not doing anything, just vibing there.--disable-dirmngrโ fully disables Dirmngr. Like, entirely. No dirmngr, no CRL gossip, nothing ๐ฅ--no-autostartโ do not startgpg-agentor thedirmngrif it hasn't been started yet and its service is needed. This is mostly a slay on machines where the connection togpg-agenthas been redirected to another machine. If dirmngr is required on the remote machine, you can start it manually withgpgconf --launch dirmngr๐ซถ--no-secmem-warningโ silences the warning you'd get when the so-called "secure memory" can't be used. No scary text, no problems ๐--log-file fileโ when running in server mode, appends all logging output to file. Useโsocket://โto log to a socket โญ--log-timeโ prefixes all log output with a timestamp, even when you're not using a log file. Time-stamped receipts, always โจ
๐ Certificate related options ๐
--enable-policy-checks,--disable-policy-checksโ policy checks are enabled by default, and these two let you flip that. That's it, that's the whole thing ๐--enable-crl-checks,--disable-crl-checksโ CRL checks are on by default and DirMngr is the one checking for revoked certificates. The disable option is genuinely useful with an off-line network connection: it suppresses the check and stops new certificates from sneaking in a web bug by including a certificate-specific CRL DP ๐ The disable option also kills the issuer certificate lookup via theauthorityInfoAccessproperty of the certificate โ but--enable-issuer-key-retrievecan be used to make use of that property anyway. So yeah, you got options.--enable-trusted-cert-crl-check,--disable-trusted-cert-crl-checkโ by default the CRL for trusted root certificates gets checked just like any other certificate. This lets a CA voluntarily revoke its own certificates without having to shove every certificate it ever issued into a CRL. The disable option switches this extra check off โ and because Dirmngr does caching, you won't see any noticeable performance gain from it. Note that this also disables possible OCSP checks for trusted root certificates ๐ซ A more specific way of disabling this check is by adding therelaxkeyword to the root CA line of theโtrustlist.txtโ.--force-crl-refreshโ tells the dirmngr to reload the CRL for each request. For better performance the dirmngr actually optimizes this by suppressing the loading for short time intervals (e.g. 30 minutes). This option is useful to make sure a fresh CRL is available for certificates held in the keybox, and the suggested way of doing it is using it along with--with-validationfor a key listing command ๐ฅ
Heads up bestie: this option should not be used in a configuration file. Command line only, no cap ๐
--enable-issuer-based-crl-checkโ runs a CRL check even for certificates that don't have any CRL distribution point. This requires that a suitable LDAP server has been configured in Dirmngr and that the CRL can be found using the issuer. It reverts to what GnuPG did up to version 2.2.20. Honestly? This option is in general not useful ๐--enable-ocsp,--disable-ocspโ OCSP checks are disabled by default. The enable option lets you turn on OCSP checks via Dirmngr ๐ฆ If CRL checks are also enabled, CRLs get used as a fallback if an OCSP request doesn't succeed for some reason. Note that you also have to allow OCSP requests in Dirmngr's configuration (option--allow-ocsp) and configure Dirmngr properly. If you don't, you'll get the error codeโNot supportedโโ and not in a cute way ๐ญ--auto-issuer-key-retrieveโ if a required certificate is missing while validating the chain of certificates, try to load that certificate from an external location. Usually that means Dirmngr gets employed to search for it ๐
Real talk: this option makes a "web bug"-like behavior possible. LDAP server operators can see which keys you request, so by sending you a message signed by a brand new key (which you naturally won't have on your local keybox), the operator can tell both your IP address and the time when you verified the signature. Kinda creepy, lowkey ๐
Note that if CRL checking is not disabled, issuer certificates are retrieved in any case using the caIssuers authorityInfoAccess method.
--validation-model nameโ changes the default validation model. The only possible values are"shell"(which is the default),"chain"which forces the use of the chain model, and"steed"for a new simplified model ๐ด The chain model is also used if an option in theโtrustlist.txtโor an attribute of the certificate requests it โ however the standard model (shell) is in that case always tried first.--ignore-cert-extension oidโ adds oid to the list of ignored certificate extensions. The oid should be in dotted decimal form, like2.5.29.3. This option may be used more than once โจ Critical-flagged certificate extensions matching one of the OIDs in the list get treated as if they're actually handled, so the certificate won't be rejected due to an unknown critical extension.
Use this one with care, bestie โ extensions are usually flagged as critical for a reason ๐ฉ
๐ธ Input and Output ๐ธ
--armor,-aโ creates PEM encoded output. Default is binary output ๐--base64โ creates Base-64 encoded output; i.e. PEM without the header lines. Strip it down, still iconic ๐--assume-armorโ assumes the input data is PEM encoded. Default is to autodetect the encoding, but that may fail ๐ (yes, it's "may", not "will" โ autodetect is doing its best).--assume-base64โ assumes the input data is plain base-64 encoded.--assume-binaryโ assumes the input data is binary encoded.--input-size-hint nโ tells GPGSM the size of the input data in bytes. n must be a positive base-10 number โญ It's used by the--status-fdlinePROGRESSto provide a value fortotalif that isn't available by other means.--p12-charset nameโgpgsmuses the UTF-8 encoding when encoding passphrases for PKCS#12 files. This option forces the passphrase to be encoded in the encoding name you specify ๐ฆ Useful if the application used to import the key uses a different encoding and thus won't be able to import a file generated by gpgsm. Commonly used values for name areLatin1andCP850. And note that gpgsm itself automagically imports any file with a passphrase encoded to the most commonly used encodings โ so it's got range ๐--default-key user_idโ uses user_id as the standard key for signing. This key is used if no other key has been defined as a signing key ๐ Note that the first--local-usersoption also sets this key if it hasn't been set yet; however--default-keyalways overrides this. Always. It's giving main character energy.--local-user user_id,-u user_idโ sets the user(s) to be used for signing. The default is the first secret key found in the database ๐--recipient name,-rโ encrypts to the user id name. There are several ways a user id may be given (see: [how-to-specify-a-user-id]) โจ--output file,-o fileโ writes output to file. The default is to write it to stdout, the classic ๐--with-key-dataโ displays extra information with the--list-keyscommands. Especially a line taggedgrpis printed, which tells you the keygrip of a key ๐ That string is for example used as the file name of the secret key. Implies--with-colons.--with-validationโ when doing a key listing, does a full validation check for each key and prints the result. This is usually a slow operation because it requires a CRL lookup and other operations ๐
When used along with --import, a validation of the certificate to import is done and it's only imported if it succeeds the test. Note that this does not affect an already available certificate in the DB. This option is therefore useful to simply verify a certificate โ vibe check, but for certs โ
--with-md5-fingerprintโ for standard key listings, also prints the MD5 fingerprint of the certificate ๐ธ--with-keygripโ includes the keygrip in standard key listings. Note that the keygrip is always listed in--with-colonsmode, so this is only for the standard listing bestie ๐--with-secretโ includes info about the presence of a secret key in public key listings done with--with-colons๐คซ--no-pretty-dnโ by default gpgsm prints distinguished names (DNs) like the Issuer or Subject in a more readable format (e.g. using a well defined order of the parts). However, this format can't be used as input strings ๐ซ This option reverts printing to standard RFC-2253 format and thus avoids the need to use--dump-certor--with-colonsto get therealname. Feral-but-functional formatting, we respect it.
๐ How to change how the CMS is created ๐
--include-certs nโ using n of-2includes all certificate except for the root cert,-1includes all certs,0does not include any certs,1includes only the signers cert, and all other positive values include up to n certificates starting with the signer cert. The default is-2โญ--cipher-algo oidโ uses the cipher algorithm with the ASN.1 object identifier oid for encryption. For convenience the strings3DES,AESandAES256may be used instead of their OIDs ๐ฅ The default isAES(2.16.840.1.101.3.4.1.2).--digest-algo nameโ uses 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 ๐ญ
Like, severe severe. You've been warned, bestie ๐
๐ Doing things one usually do not want to do ๐
--chuid uidโ changes the current user to uid, which may either be a number or a name. This can be used from the root account to run gpgsm for another user ๐ If uid is not the current UID, a standardPATHis set and the envvarGNUPGHOMEis unset. To override the latter, use the option--homedir. This option has only an effect when used on the command line. And it currently has no effect at all on Windows ๐ช
Okay, more flags, because the option list said โmoreโ and meant it ๐
--extra-digest-algoname โ So sometimes signatures are lowkey broken: they announce a different digest algorithm than the one actually used ๐ญ.gpgsmruns a one-pass data processing model, so it has to trust the announced digest algorithms to hash the data properly. As a workaround, this option tellsgpgsmto also hash the data using the algorithm name. It slows processing down a little bit, but it lets you verify those broken signatures. Ifgpgsmprints an error likedigest algo 8 has not been enabled, you may want to try this option withSHA256for name. โจ--compliancestring โ Set the compliance mode. Valid values are shown when you usehelpfor string. Compliance era: activated ๐--min-rsa-lengthn โ This option adjusts thede-vscompliance mode for stricter key size requirements. For example, a value of3000turnsrsa2048anddsa2048keys into non-VS-NfD compliant keys. So yes, size matters here ๐ฅ--require-complianceโ To check that data has been encrypted according to the rules of the current compliance mode, agpgsmuser needs to evaluate the status lines. This allows frontends to handle compliance checks in a more flexible way. But for scripted use, that required status-line evaluation is a lot of effort ๐ญ. This option can be used instead to make sure thegpgsmprocess exits with a failure if the compliance rules are not fulfilled. Note that this option currently has an effect only inde-vsmode.--assert-signerfpr_or_file โ This option checks whether at least one valid signature on a file was made with the specified key. The key is either a fingerprint or a file listing fingerprints. The fingerprint must be given or listed in compact format (no colons or spaces in between). As of now only SHA-1 fingerprints are allowed. This option can be given multiple times, and each fingerprint is checked against the signing key as well as the corresponding primary key. If fpr_or_file specifies a file, empty lines are ignored, as are all lines starting with a hash sign. With this option,gpgsmis guaranteed to return with an exit code of0if and only if a signature has been encountered, is valid, and the key matches one of the fingerprints given by this option. Periodt โ--always-trustโ Force encryption to the specified certificates without any validation of the certificate chain. The only requirement is that the certificate is capable of encryption. Note that this option is ineffective if--require-complianceis used. So yeah, trust issues? Not today ๐--ignore-cert-with-oidoid โ Add oid to the list of OIDs to be checked while reading certificates from smartcards. The oid is expected to be in dotted decimal form, like2.5.29.3. This option may be used more than once. As of now, certificates with an extended key usage matching one of those OIDs are ignored during a--learn-cardoperation and not imported. This option can help keep the local key database clear of unneeded certificates stored on smartcards. Smartcard cleanup era ๐งน--faked-system-timeepoch โ This option is only useful for testing. It sets the system time back or forth to epoch, which is the number of seconds elapsed since the year 1970. Alternatively, epoch may be given as a full ISO time string (e.g.20070924T154812). Time travel but make it QA ๐ฐ๏ธ--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 fingerprint or keygrip. Lowkey ephemeral main character energy โจ--compatibility-flagsflags โ Set compatibility flags to work around problems due to non-compliant certificates or data. The flags are given as a comma separated list of flag names and are OR-ed together. The special flagnoneclears the list and lets you start over with an empty list. To get a list of available flags, use the sole wordhelp. Compatibility era: activated ๐ ๏ธ--debug-levellevel โ Select the debug level for investigating problems. level may be a numeric value or one of these keywords:noneโ No debugging at all. A value of less than1may be used instead of the keyword.basicโ Some basic debug messages. A value between1and2may be used instead of the keyword.advancedโ More verbose debug messages. A value between3and5may be used instead of the keyword.expertโ Even more detailed messages. A value between6and8may be used instead of the keyword.guruโ All of the debug messages you can get. A value greater than8may be used instead of the keyword. The creation of hash tracing files is only enabled if the keyword is used. Guru mode is not for the faint of heart ๐
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. So donโt build your whole personality around the exact mapping, bestie ๐ญ
--debugflags โ Set debug flags. All flags are or-ed and flags 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, use the single wordhelp. This option is only useful for debugging, and the behavior may change at any time without notice. Note that all flags set using this option may get overridden by--debug-level. Debug chaos: iconic but unstable ๐--debug-allโ Same as--debug=0xffffffff. All the debug, all at once ๐ฅ--debug-allow-core-dumpโ Usuallygpgsmtries to avoid dumping core by well-written code and by disabling core dumps for security reasons. However, bugs are pretty durable beasts, and to squash them it is sometimes useful to have a core dump. This option enables core dumps unless the Bad Thing happened before the option parsing. Core dump but make it forensic ๐ซถ--debug-no-chain-validationโ This is actually not a debugging option, but itโs only useful as one. It letsgpgsmbypass all certificate chain validation checks. Chain validation? Never heard of her (for debug only, iykyk) ๐--debug-ignore-expirationโ This is actually not a debugging option, but itโs only useful as one. It letsgpgsmignore allnotAfterdates; this is used by the regression tests. Expiration? Ignored. The regression tests said so ๐ง--passphrase-fdn โ Read the passphrase from file descriptor n. Only the first line will be read from file descriptor n. If you use0for n, the passphrase will be read fromSTDIN. This can only be used if only one passphrase is supplied. Note that this passphrase is only used if the option--batchhas also been given. Passphrase delivery, but make it file descriptor chic ๐--pinentry-modemode โ Set the pinentry mode to mode. Allowed values for mode are:defaultโ Use the default of the agent, which isask.askโ Force the use of the Pinentry.cancelโ Emulate use of Pinentryโs cancel button.errorโ Return a Pinentry error (No Pinentry).loopbackโ Redirect Pinentry queries to the caller. Note that in contrast to Pinentry, the user is not prompted again if they enter a bad password. Loopback said โno second chancesโ ๐
--request-originorigin โ Tellgpgsmto assume that the operation ultimately originated at origin. Depending on the origin, certain restrictions are applied and the Pinentry may include an extra note on the origin. Supported values for origin are:local, which is the default;remote, to indicate a remote origin; orbrowser, for an operation requested by a web browser. Origin story but make it cryptographic ๐--no-common-certs-importโ Suppress the import of common certificates on keybox creation. No common certs, no common problems (okay thatโs just a vibe, not a spec ๐)
All the long options may also be given in the configuration file after stripping off the two leading dashes. Config file era: noted ๐
โจ HOW TO SPECIFY A USER ID โจ
Okay so bestie, there are like several ways to hand GnuPG a user ID, and ngl it's giving "choose your fighter" ๐
. Some of these are only valid for gpg, others are only good for gpgsm โ so check before you commit, mkay? Here's the entire list of ways to specify a key:
By key Id ๐
This format is deduced from the length of the string and its content, or from a 0x prefix. The key Id of an X.509 certificate is the low 64 bits of its SHA-1 fingerprint. Using key Ids is just a shortcut, fr fr โ for all automated processing the fingerprint should be used.
When using gpg, an exclamation mark (!) may be appended to force using the specified primary or secondary key and not to try and calculate which primary or secondary key to use.
The last four lines of the example give the key ID in their long form as internally used by the OpenPGP protocol. You can see the long key ID using the option --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 gpgsm (i.e. the SHA-1 hash of the certificate). lowkey important.
When using gpg, an exclamation mark (!) may be appended to force using the specified primary or secondary key and not to try and calculate which primary or secondary key to use.
The best way to specify a key Id is by using the fingerprint โ it's the main character move ๐. This avoids any ambiguities in case 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. gpg also allows the use of the space separated SHA-1 fingerprint as printed by the key listing commands. Slay ๐
By exact match on OpenPGP user ID ๐ชช
This is denoted by a leading equal sign. It does not make sense for X.509 certificates (just so you know ๐).
=Heinrich Heine <heinrichh@uni-duesseldorf.de>
By exact match on an email address ๐ง
This is indicated by enclosing the email address in the usual way with left and right angles.
<heinrichh@uni-duesseldorf.de>
By partial match on an email address ๐
This is indicated by prefixing the search string with an @. It uses a substring search but considers only the mail address (i.e. the part inside the angle brackets).
@heinrichh
By exact match on the subject's DN ๐
This is indicated by a leading slash, directly followed by the RFC-2253 encoded DN of the subject. Note that you can't use the string printed by gpgsm --list-keys because that one has been reordered and modified for better readability โ rude, I know ๐ญ โ 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 then directly followed by the RFC-2253 encoded DN of the issuer. This should return 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 the 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.
&D75F22C3F86E355877348498CDC92BD21010A480
By substring match ๐งต
This is the default mode, but applications may want to explicitly indicate this by putting the asterisk in front. Match is not case sensitive.
Heine
*Heine
. and + prefixes ๐
These prefixes are reserved for looking up mails anchored at the end, and for a word search mode. They are not yet implemented and using them is undefined โ so don't, bestie, it's giving chaos energy ๐.
Please note that we have reused the hash mark identifier which was used in old GnuPG versions to indicate the so called local-id. It is not anymore used and there 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 our key database stores this encoding as meta data. Cute, right? ๐
๐ธ EXAMPLES ๐ธ
A whole one (1) example, and it eats:
$ gpgsm -er goo@bar.net <plaintext >ciphertext
๐ FILES ๐
There are a few configuration files to control certain aspects of gpgsm's operation. Unless noted, they are expected in the current home directory (see: [option --homedir]). The way this crew is organized >>>
gpgsm.confโ this is the standard configuration file read bygpgsmon startup. It may contain any valid long option; the leading two dashes may not be entered and the option may not be abbreviated. This default name may be changed on the command line (see: [gpgsm-option--options]). You should backup this file ๐ซถ.common.confโ this is an optional configuration file read bygpgsmon startup. It may contain options pertaining to all components of GnuPG. Its current main use is for the"use-keyboxd"option.policies.txtโ this is a list of allowed CA policies. This file should list the object identifiers of the policies line by line. Empty lines and lines starting with a hash mark are ignored. Policies missing in this file and not marked as critical in the certificate will print only a warning; certificates with policies marked as critical and not listed in this file will fail the signature verification ๐ฑ. You should backup this file.
For example, to allow only the policy 2.289.9.9, the file should look like this:
# Allowed policies
2.289.9.9
qualified.txtโ this is the legacy method to mark root certificates as usable for qualified certificates. Qualified certificates are capable of creating legally binding signatures in the same way as handwritten signatures โ๏ธ. The modern method to mark such root certificates is to use the"qual"flag in the systemtrustlist.txt; see the gpg-agent man page for details.
Comments int his file start with a hash mark and empty lines are ignored. Lines do have a length limit but this is not a serious limitation as the format of the entries is fixed and checked by gpgsm: a non-comment line starts with optional whitespace, followed by exactly 40 hex characters, white space and a lowercased 2 letter country code. Additional data delimited with by a white space is current ignored but might late be used for other purposes.
Note that even if a certificate is listed in this file, this does not mean that the certificate is trusted; in general the certificates listed in this file need to be listed also in trustlist.txt. This is a global file an installed in the sysconf directory (e.g. /etc/gnupg/qualified.txt).
Every time gpgsm uses a certificate for signing or verification this file will be consulted to check whether the certificate under question has ultimately been issued by one of these CAs. If this is the case the user will be informed that the verified signature represents a legally binding ("qualified") signature. When creating a signature using such a certificate an extra prompt will be issued 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 certificates, appropriate notices will be shown to indicate this fact ๐ง.
help.txtโ this is plain text file with a few help entries used withpinentryas well as a large list of help items forgpgandgpgsm. The standard file has English help texts; to install localized versions use filenames likehelp.LL.txtwithLLdenoting the locale. GnuPG comes with a set of predefined help files in the data directory (e.g./usr/share/gnupg/gnupg/help.de.txt) and allows overriding of any help item by help files stored in the system configuration directory (e.g./etc/gnupg/help.de.txt). For a reference of the help file's syntax, please see the installedhelp.txtfile.com-certs.pemโ this file is a collection of common certificates used to populated a newly createdpubring.kbx. An administrator may replace this file with a custom one. The format is a concatenation of PEM encoded X.509 certificates. This global file is installed in the data directory (e.g./usr/share/gnupg/com-certs.pem).
Note that on larger installations, it is useful to put predefined files into the directory/etc/skel/.gnupg/so that newly created users start up with a working configuration. For existing users a small helper script is provided to create these files (see: [addgnupghome]).
For internal purposes gpgsm creates and maintains a few other files; they all live in the current home directory (see: [option --homedir]). Only gpgsm may modify these files โ hands off, bestie ๐
โโ๏ธ.
pubring.kbxโ this a database file storing the certificates as well as meta information. For debugging purposes the toolkbxutilmay be used to show the internal structure of this file. You should backup this file.random_seedโ this content of this file is used to maintain the internal state of the random number generator across invocations. The same file is used by other programs of this software too ๐ฒ.S.gpg-agentโ if this file existsgpgsmwill first try to connect to this socket for accessinggpg-agentbefore starting a newgpg-agentinstance. Under Windows this socket (which in reality be a plain file describing a regular TCP listening port) is the standard way of connecting thegpg-agent๐ช.
โจ SEE ALSO โจ
okay so like, you're not gonna be living in gpgsm alone forever bestie โ these two are literally its ride-or-dies, go check them out ๐
gpg(1)โ the classic OpenPGP one, the main character of the GnuPG fam ๐ซถgpg-agent(1)โ the little daemon that holds your keys and passphrases so you don't have to type them every five seconds, slay ๐
๐ THE FULL DOCUMENTATION ๐
ngl, this page is likeโฆ the summary. The real, full-length lore is maintained as a Texinfo manual โ that's the big-boss version of the docs ๐
So if GnuPG and the info program are properly installed on your system (both of them, no cap), then this command right here:
info gnupg
should give you access to the complete manual, and it's giving menu structure and an index, so you can actually navigate the whole thing instead of scrolling forever ๐ญ๐ฅ
fr fr though โ if that command gives you nothing, it's notgpgsmbeing shady, it just means the info files or theinfoviewer aren't installed where you're at ๐
โจ๐ that's the whole page, bestie, you made it to the end ๐โจ
๐ This was GnuPG 2.4.9, dated 2025-02-19, and yes, the page is literally called GPGSM(1) โ go forth and manage those S/MIME certs, you absolute icon ๐๐ฆ๐ธ
๐ฆ where this page comes from
- alpine 3.22: gnupg-doc 2.4.9-r0 ยท GPL-3.0-or-later
- alpine 3.23: gnupg-doc 2.4.9-r0 ยท GPL-3.0-or-later
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms