p11tool(1) | User Commands | p11tool(1) |
p11tool - GnuTLS PKCS #11 tool
p11tool [-flags] [-flag [value]] [--option-name[[=| ]value]] [url]
Operands and options may be intermixed. They will be reordered.
Program that allows operations on PKCS #11 smart cards and security modules.
To use PKCS #11 tokens with GnuTLS the p11-kit configuration files need to be setup. That is create a .module file in /etc/pkcs11/modules with the contents 'module: /path/to/pkcs11.so'. Alternatively the configuration file /etc/gnutls/pkcs11.conf has to exist and contain a number of lines of the form 'load=/usr/lib/opensc-pkcs11.so'.
You can provide the PIN to be used for the PKCS #11 operations with the environment variables GNUTLS_PIN and GNUTLS_SO_PIN.
This is a more compact version of --list-tokens.
This initializes the security officer's PIN. When used non-interactively use the GNUTLS_NEW_SO_PIN environment variables to initialize SO's PIN.
Alternatively the GNUTLS_PIN environment variable may be used.
Alternatively the GNUTLS_SO_PIN environment variable may be used.
All objects available in the token will be listed. That includes objects which are potentially unaccessible using this tool.
That option will also provide more information on the certificates, for example, expand the attached extensions in a trust token (like p11-kit-trust).
That option will only display certificates which have a private key associated with them (share the same ID).
Lists all the private keys in a token that match the specified URL.
Exports the certificate specified by the URL while including any attached extensions to it. Since attached extensions are a p11-kit extension, this option is only available on p11-kit registered trust modules.
Exports the certificate specified by the URL and generates its chain of trust based on the stored certificates in the module.
Exports the public key for the specified private key
Generates a private-public key pair in the specified token. Acceptable types are RSA, ECDSA, Ed25519, and DSA. Should be combined with --sec-param or --bits.
Generates an RSA private-public key pair on the specified token. Should be combined with --sec-param or --bits.
NOTE: THIS OPTION IS DEPRECATED
Generates a DSA private-public key pair on the specified token. Should be combined with --sec-param or --bits.
NOTE: THIS OPTION IS DEPRECATED
Generates an ECDSA private-public key pair on the specified token. Should be combined with --curve, --sec-param or --bits.
NOTE: THIS OPTION IS DEPRECATED
For applications which have no key-size restrictions the --sec-param option is recommended, as the sec-param levels will adapt to the acceptable security levels with the new versions of gnutls.
Supported values are secp192r1, secp224r1, secp256r1, secp384r1 and secp521r1.
This is alternative to the bits option. Available options are [low, legacy, medium, high, ultra].
Modifies or sets the CKA_ID in the specified by the URL object. The ID should be specified in hexadecimal format without a '0x' prefix.
Modifies or sets the CKA_LABEL in the specified by the URL object
It can be used to write private, public keys, certificates or
secret keys to a token. Must be combined with
one of --load-privkey, --load-pubkey, --load-certificate option.
Sets the CKA_ID to be set by the write operation. The ID should be specified in hexadecimal format without a '0x' prefix.
Marks the generated key with the CKA_WRAP flag.
Marks the object to be generated/written with the CKA_TRUST flag.
Ensures that the objects retrieved have the CKA_X_TRUST flag. This is p11-kit trust module extension, thus this flag is only valid with p11-kit registered trust modules.
Marks the object to be generated/written with the CKA_DECRYPT flag set to true.
Marks the object to be generated/written with the CKA_SIGN flag set to true.
Marks the object to be generated/written with the CKA_CERTIFICATE_CATEGORY as CA.
Marks the object to be generated/written with the CKA_PRIVATE flag. The written object will require a PIN to be used.
This secret key will be written to the module if --write is specified.
in the range 0 through 9999
Specifies the debug level.
Forces login to the token as security officer (admin).
It can be used to test the correct operation of the signature operation. If both a private and a public key are available this operation will sign and verify the signed data.
This option can be combined with --test-sign, to sign with a specific signature algorithm variant. The only option supported is 'RSA-PSS', and should be specified in order to use RSA-PSS signature on RSA keys.
This option can be combined with test-sign. Available hash functions are SHA1, RMD160, SHA256, SHA384, SHA512, SHA3-224, SHA3-256, SHA3-384, SHA3-512.
Asks the token to generate a number of bytes of random bytes.
Use DER/RAW format for input certificates and private keys.
The output will be in DER or RAW format.
This will override the default options in /etc/gnutls/pkcs11.conf
This is a PKCS#11 internal option used by few modules.
Mainly for testing PKCS#11 modules.
NOTE: THIS OPTION IS DEPRECATED
In batch mode there will be no prompts, all parameters need to be specified on command line.
To view all tokens in your system use:
$ p11tool --list-tokens
To view all objects in a token use:
$ p11tool --login --list-all "pkcs11:TOKEN-URL"
To store a private key and a certificate in a token run:
$ p11tool --login --write "pkcs11:URL" --load-privkey key.pem --label "Mykey" $ p11tool --login --write "pkcs11:URL" --load-certificate cert.pem --label "Mykey"
Note that some tokens require the same label to be used for the certificate and its corresponding private key.
To generate an RSA private key inside the token use:
$ p11tool --login --generate-privkey rsa --bits 1024 --label "MyNewKey" --outfile MyNewKey.pub "pkcs11:TOKEN-URL"The bits parameter in the above example is explicitly set because some tokens only support limited choices in the bit length. The output file is the corresponding public key. This key can be used to general a certificate request with certtool.
certtool --generate-request --load-privkey "pkcs11:KEY-URL" --load-pubkey MyNewKey.pub --outfile request.pem
One of the following exit values will be returned:
certtool (1)
Nikos Mavrogiannopoulos, Simon Josefsson and others; see /usr/share/doc/gnutls/AUTHORS for a complete list.
Copyright (C) 2000-2020 Free Software Foundation, and others all rights reserved. This program is released under the terms of the GNU General Public License, version 3 or later.
Please send bug reports to: bugs@gnutls.org
This manual page was AutoGen-erated from the p11tool option definitions.
2023-11-30 | 3.7.1 |