p11tool - GnuTLS PKCS #11 tool
Usage: p11tool [ -<flag> [<val>] | --<name>[{=| }<val>] ]... [url]
None:
Tokens:
--list-tokens List all available tokens
--list-token-urls List the URLs available tokens
--list-mechanisms List all available mechanisms in a token
--initialize Initializes a PKCS #11 token
--initialize-pin Initializes/Resets a PKCS #11 token user PIN
--initialize-so-pin Initializes/Resets a PKCS #11 token security officer PIN
--set-pin=str Specify the PIN to use on token operations
--set-so-pin=str Specify the Security Officer's PIN to use on token initialization
Object listing:
--list-all List all available objects in a token
--list-all-certs List all available certificates in a token
--list-certs List all certificates that have an associated private key
--list-all-privkeys List all available private keys in a token
--list-privkeys an alias for the 'list-all-privkeys' option
--list-keys an alias for the 'list-all-privkeys' option
--list-all-trusted List all available certificates marked as trusted
--export Export the object specified by the URL
- prohibits these options:
export-stapled
export-chain
export-pubkey
--export-stapled Export the certificate object specified by the URL
- prohibits these options:
export
export-chain
export-pubkey
--export-chain Export the certificate specified by the URL and its chain of trust
- prohibits these options:
export-stapled
export
export-pubkey
--export-pubkey Export the public key for a private key
- prohibits these options:
export-stapled
export
export-chain
--info List information on an available object in a token
--trusted an alias for the 'mark-trusted' option
--distrusted an alias for the 'mark-distrusted' option
Key generation:
--generate-privkey=str Generate private-public key pair of given type
--bits=num Specify the number of bits for the key generate
--curve=str Specify the curve used for EC key generation
--sec-param=str Specify the security level
Writing objects:
--set-id=str Set the CKA_ID (in hex) for the specified by the URL object
- prohibits the option 'write'
--set-label=str Set the CKA_LABEL for the specified by the URL object
- prohibits these options:
write
set-id
--write Writes the loaded objects to a PKCS #11 token
--delete Deletes the objects matching the given PKCS #11 URL
--label=str Sets a label for the write operation
--id=str Sets an ID for the write operation
--mark-wrap Marks the generated key to be a wrapping key
--mark-trusted Marks the object to be written as trusted
- prohibits the option 'mark-distrusted'
--mark-distrusted When retrieving objects, it requires the objects to be distrusted
- prohibits the option 'mark-trusted'
--mark-decrypt Marks the object to be written for decryption
--mark-sign Marks the object to be written for signature generation
--mark-ca Marks the object to be written as a CA
--mark-private Marks the object to be written as private
--ca an alias for the 'mark-ca' option
--private an alias for the 'mark-private' option
--mark-always-authenticate Marks the object to be written as always authenticate
--secret-key=str Provide a hex encoded secret key
--load-privkey=file Private key file to use
- file must pre-exist
--load-pubkey=file Public key file to use
- file must pre-exist
--load-certificate=file Certificate file to use
- file must pre-exist
Other options:
-d, --debug=num Enable debugging
- it must be in the range:
0 to 9999
--outfile=str Output file
--login Force (user) login to token
--so-login Force security officer login to token
--admin-login an alias for the 'so-login' option
--test-sign Tests the signature operation of the provided object
--sign-params=str Sign with a specific signature algorithm
--hash=str Hash algorithm to use for signing
--generate-random=num Generate random data
-8, --pkcs8 Use PKCS #8 format for private keys
--inder Use DER/RAW format for input
--inraw an alias for the 'inder' option
--outder Use DER format for output certificates, private keys, and DH parameters
--outraw an alias for the 'outder' option
--provider=file Specify the PKCS #11 provider library
--detailed-url Print detailed URLs
--only-urls Print a compact listing using only the URLs
--batch Disable all interaction with the tool
Version, usage and configuration options:
-v, --version[=arg] output version information and exit
-h, --help display extended usage information and exit
-!, --more-help extended usage information passed thru pager
Options are specified by doubled hyphens and their name or by a single
hyphen and the flag character.
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.
Please send bug reports to: <bugs@gnutls.org>
Options (71)
| Option | Description | Source |
|---|---|---|
--list-tokens | List all available tokens. | help + man |
--list-token-urls | List the URLs available tokens. | help + man |
--list-mechanisms | List all available mechanisms in a token. | help + man |
--initialize | Initializes a PKCS #11 token. | help + man |
--initialize-pin | Initializes/Resets a PKCS #11 token user PIN. | help + man |
--initialize-so-pin | Initializes/Resets a PKCS #11 token security officer PIN. | help + man |
--set-pin str | Specify the PIN to use on token operations. | help + man |
--set-so-pin str | Specify the Security Officer's PIN to use on token initialization. | help + man |
--list-all | List all available objects in a token. | help + man |
--list-all-certs | List all available certificates in a token. | help + man |
--list-certs | List all certificates that have an associated private key. | help + man |
--list-all-privkeys | List all available private keys in a token. | help + man |
--list-privkeys | This is an alias for the --list-all-privkeys option. | help + man |
--list-keys | This is an alias for the --list-all-privkeys option. | help + man |
--list-all-trusted | List all available certificates marked as trusted. | help + man |
--export | Export the object specified by the URL. | help + man |
--export-stapled | Export the certificate object specified by the URL. | help + man |
--export-chain | Export the certificate specified by the URL and its chain of trust. | help + man |
--export-pubkey | Export the public key for a private key. | help + man |
--info | List information on an available object in a token. | help + man |
--trusted | This is an alias for the --mark-trusted option. | help + man |
--distrusted | This is an alias for the --mark-distrusted option. | help + man |
--bits num | Specify the number of bits for the key generate. | help + man |
--curve str | Specify the curve used for EC key generation. | help + man |
--sec-param str | Specify the security level. | help + man |
--set-id str | Set the CKA_ID (in hex) for the specified by the URL object. | help + man |
--set-label str | Set the CKA_LABEL for the specified by the URL object. | help + man |
--write | Writes the loaded objects to a PKCS #11 token. | help + man |
--delete | Deletes the objects matching the given PKCS #11 URL. | help + man |
--label str | Sets a label for the write operation. | help + man |
--id str | Sets an ID for the write operation. | help + man |
--mark-wrap, --no-mark-wrap | Marks the generated key to be a wrapping key. | help + man |
--mark-trusted, --no-mark-trusted | Marks the object to be written as trusted. | help + man |
--mark-distrusted | When retrieving objects, it requires the objects to be distrusted. | help + man |
--mark-decrypt, --no-mark-decrypt | Marks the object to be written for decryption. | help + man |
--mark-sign, --no-mark-sign | Marks the object to be written for signature generation. | help + man |
--mark-ca, --no-mark-ca | Marks the object to be written as a CA. | help + man |
--mark-private, --no-mark-private | Marks the object to be written as private. | help + man |
--ca | This is an alias for the --mark-ca option. | help + man |
--private | This is an alias for the --mark-private option. | help + man |
--mark-always-authenticate, --no-mark-always-authenticate | Marks the object to be written as always authenticate. | help + man |
--secret-key str | Provide a hex encoded secret key. | help + man |
--load-privkey file | Private key file to use. | help + man |
--load-pubkey file | Public key file to use. | help + man |
-d, --debug num | Enable debugging. | help + man |
--outfile str | Output file. | help + man |
--login, --no-login | Force (user) login to token. | help + man |
--so-login, --no-so-login | Force security officer login to token. | help + man |
--admin-login | This is an alias for the --so-login option. | help + man |
--test-sign | Tests the signature operation of the provided object. | help + man |
--sign-params str | Sign with a specific signature algorithm. | help + man |
--hash str | Hash algorithm to use for signing. | help + man |
--generate-random num | Generate random data. | help + man |
-8, --pkcs8 | Use PKCS #8 format for private keys. | help + man |
--inder, --no-inder | Use DER/RAW format for input. | help + man |
--inraw | This is an alias for the --inder option. | help + man |
--outder, --no-outder | Use DER format for output certificates, private keys, and DH parameters. | help + man |
--outraw | This is an alias for the --outder option. | help + man |
--provider file | Specify the PKCS #11 provider library. | help + man |
--detailed-url, --no-detailed-url | Print detailed URLs. | help + man |
--only-urls | Print a compact listing using only the URLs. | help + man |
--batch | Disable all interaction with the tool. | help + man |
-v, --version arg | output version information and exit | help + man |
-h, --help | display extended usage information and exit | help + man |
--more-help | Pass the extended usage information through a pager. | help + man |
--generate-privkey str | Generate private-public key pair of given type. (in the manual page but not in --help) | man |
--generate-rsa | Generate an RSA private-public key pair. (in the manual page but not in --help) | man |
--generate-dsa | Generate a DSA private-public key pair. (in the manual page but not in --help) | man |
--generate-ecc | Generate an ECDSA private-public key pair. (in the manual page but not in --help) | man |
--load-certificate file | Certificate file to use. (in the manual page but not in --help) | man |
--provider-opts str | Specify parameters for the PKCS #11 provider library. (in the manual page but not in --help) | man |
Examples (6) from the manual page, untested
p11tool --list-tokens
To view all tokens in your system use:p11tool --login --list-all "pkcs11:TOKEN-URL"
To view all objects in a token use:p11tool --login --write "pkcs11:URL" --load-privkey key.pem --label "Mykey"
To store a private key and a certificate in a token run:p11tool --login --write "pkcs11:URL" --load-certificate cert.pem --label "Mykey"
To store a private key and a certificate in a token run:p11tool --login --generate-privkey rsa --bits 1024 --label "MyNewKey" --outfile MyNewKey.pub "pkcs11:TOKEN-URL"
To generate an RSA private key inside the token use:certtool --generate-request --load-privkey "pkcs11:KEY-URL" --load-pubkey MyNewKey.pub --outfile request.pem
The bits parameter in the above example is explicitly set because some tokens only support limited choices in the bit length.