         --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>


token-related-options options
.............................

Tokens.

list-token-urls option.
.......................

This is the "list the urls available tokens" option.  This is a more
compact version of -list-tokens.

initialize-so-pin option.
.........................

This is the "initializes/resets a pkcs #11 token security officer pin"
option.  This initializes the security officer's PIN. When used
non-interactively use the GNUTLS_NEW_SO_PIN environment variables to
initialize SO's PIN.

set-pin option.
...............

This is the "specify the pin to use on token operations" option.  This
option takes a ArgumentType.STRING argument.  Alternatively the
GNUTLS_PIN environment variable may be used.

set-so-pin option.
..................

This is the "specify the security officer's pin to use on token
initialization" option.  This option takes a ArgumentType.STRING
argument.  Alternatively the GNUTLS_SO_PIN environment variable may be
used.

object-list-related-options options
...................................

Object listing.

list-all option.
................

This is the "list all available objects in a token" option.  All objects
available in the token will be listed.  That includes objects which are
potentially unaccessible using this tool.

list-all-certs option.
......................

This is the "list all available certificates in a token" option.  That
option will also provide more information on the certificates, for
example, expand the attached extensions in a trust token (like
p11-kit-trust).

list-certs option.
..................

This is the "list all certificates that have an associated private key"
option.  That option will only display certificates which have a private
key associated with them (share the same ID).

list-all-privkeys option.
.........................

This is the "list all available private keys in a token" option.  Lists
all the private keys in a token that match the specified URL.

list-privkeys option.
.....................

This is an alias for the ‘list-all-privkeys’ option, *note the
list-all-privkeys option documentation: p11tool list-all-privkeys.

list-keys option.
.................

This is an alias for the ‘list-all-privkeys’ option, *note the
list-all-privkeys option documentation: p11tool list-all-privkeys.

export-stapled option.
......................

This is the "export the certificate object specified by the url" option.

This option has some usage constraints.  It:
   • must not appear in combination with any of the following options:
     export, export-chain, export-pubkey.

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.

export-chain option.
....................

This is the "export the certificate specified by the url and its chain
of trust" option.

This option has some usage constraints.  It:
   • must not appear in combination with any of the following options:
     export-stapled, export, export-pubkey.

Exports the certificate specified by the URL and generates its chain of
trust based on the stored certificates in the module.

export-pubkey option.
.....................

This is the "export the public key for a private key" option.

This option has some usage constraints.  It:
   • must not appear in combination with any of the following options:
     export-stapled, export, export-chain.

Exports the public key for the specified private key

trusted option.
...............

This is an alias for the ‘mark-trusted’ option, *note the mark-trusted
option documentation: p11tool mark-trusted.

distrusted option.
..................

This is an alias for the ‘mark-distrusted’ option, *note the
mark-distrusted option documentation: p11tool mark-distrusted.

keygen-related-options options
..............................

Key generation.

generate-privkey option.
........................

This is the "generate private-public key pair of given type" option.
This option takes a ArgumentType.STRING argument.  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.

generate-rsa option.
....................

This is the "generate an rsa private-public key pair" option.  Generates
an RSA private-public key pair on the specified token.  Should be
combined with -sec-param or -bits.

*NOTE**: THIS OPTION IS DEPRECATED*

generate-dsa option.
....................

This is the "generate a dsa private-public key pair" option.  Generates
a DSA private-public key pair on the specified token.  Should be
combined with -sec-param or -bits.

*NOTE**: THIS OPTION IS DEPRECATED*

generate-ecc option.
....................

This is the "generate an ecdsa private-public key pair" option.
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*

bits option.
............

This is the "specify the number of bits for the key generate" option.
This option takes a ArgumentType.NUMBER argument.  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.

curve option.
.............

This is the "specify the curve used for ec key generation" option.  This
option takes a ArgumentType.STRING argument.  Supported values are
secp192r1, secp224r1, secp256r1, secp384r1 and secp521r1.

sec-param option.
.................

This is the "specify the security level" option.  This option takes a
ArgumentType.STRING argument ‘Security parameter’.  This is alternative
to the bits option.  Available options are [low, legacy, medium, high,
ultra].

write-object-related-options options
....................................

Writing objects.

set-id option.
..............

This is the "set the cka_id (in hex) for the specified by the url
object" option.  This option takes a ArgumentType.STRING argument.

This option has some usage constraints.  It:
   • must not appear in combination with any of the following options:
     write.

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.

set-label option.
.................

This is the "set the cka_label for the specified by the url object"
option.  This option takes a ArgumentType.STRING argument.

This option has some usage constraints.  It:
   • must not appear in combination with any of the following options:
     write, set-id.

Modifies or sets the CKA_LABEL in the specified by the URL object

write option.
.............

This is the "writes the loaded objects to a pkcs #11 token" option.  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.

When writing a certificate object, its CKA_ID is set to the same CKA_ID
of the corresponding public key, if it exists on the token; otherwise it
will be derived from the X.509 Subject Key Identifier of the
certificate.  If this behavior is undesired, write the public key to the
token beforehand.

id option.
..........

This is the "sets an id for the write operation" option.  This option
takes a ArgumentType.STRING argument.  Sets the CKA_ID to be set by the
write operation.  The ID should be specified in hexadecimal format
without a '0x' prefix.

mark-wrap option.
.................

This is the "marks the generated key to be a wrapping key" option.
Marks the generated key with the CKA_WRAP flag.

mark-trusted option.
....................

This is the "marks the object to be written as trusted" option.

This option has some usage constraints.  It:
   • must not appear in combination with any of the following options:
     mark-distrusted.
   • can be disabled with -no-mark-trusted.

Marks the object to be generated/written with the CKA_TRUST flag.

mark-distrusted option.
.......................

This is the "when retrieving objects, it requires the objects to be
distrusted" option.

This option has some usage constraints.  It:
   • must not appear in combination with any of the following options:
     mark-trusted.

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.

mark-decrypt option.
....................

This is the "marks the object to be written for decryption" option.
Marks the object to be generated/written with the CKA_DECRYPT flag set
to true.

mark-sign option.
.................

This is the "marks the object to be written for signature generation"
option.  Marks the object to be generated/written with the CKA_SIGN flag
set to true.

mark-ca option.
...............

This is the "marks the object to be written as a ca" option.  Marks the
object to be generated/written with the CKA_CERTIFICATE_CATEGORY as CA.

mark-private option.
....................

This is the "marks the object to be written as private" option.  Marks
the object to be generated/written with the CKA_PRIVATE flag.  The
written object will require a PIN to be used.

ca option.
..........

This is an alias for the ‘mark-ca’ option, *note the mark-ca option
documentation: p11tool mark-ca.

private option.
...............

This is an alias for the ‘mark-private’ option, *note the mark-private
option documentation: p11tool mark-private.

mark-always-authenticate option.
................................

This is the "marks the object to be written as always authenticate"
option.  Marks the object to be generated/written with the
CKA_ALWAYS_AUTHENTICATE flag.  The written object will Mark the object
as requiring authentication (pin entry) before every operation.

secret-key option.
..................

This is the "provide a hex encoded secret key" option.  This option
takes a ArgumentType.STRING argument.  This secret key will be written
to the module if -write is specified.

other-options options
.....................

Other options.

debug option (-d).
..................

This is the "enable debugging" option.  This option takes a
ArgumentType.NUMBER argument.  Specifies the debug level.

so-login option.
................

This is the "force security officer login to token" option.  Forces
login to the token as security officer (admin).

admin-login option.
...................

This is an alias for the ‘so-login’ option, *note the so-login option
documentation: p11tool so-login.

test-sign option.
.................

This is the "tests the signature operation of the provided object"
option.  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.

sign-params option.
...................

This is the "sign with a specific signature algorithm" option.  This
option takes a ArgumentType.STRING argument.  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.

hash option.
............

This is the "hash algorithm to use for signing" option.  This option
takes a ArgumentType.STRING argument.  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.

generate-random option.
.......................

This is the "generate random data" option.  This option takes a
ArgumentType.NUMBER argument.  Asks the token to generate a number of
bytes of random bytes.

inder option.
.............

This is the "use der/raw format for input" option.  Use DER/RAW format
for input certificates and private keys.

inraw option.
.............

This is an alias for the ‘inder’ option, *note the inder option
documentation: p11tool inder.

outder option.
..............

This is the "use der format for output certificates, private keys, and
dh parameters" option.  The output will be in DER or RAW format.

outraw option.
..............

This is an alias for the ‘outder’ option, *note the outder option
documentation: p11tool outder.

provider option.
................

This is the "specify the pkcs #11 provider library" option.  This option
takes a ArgumentType.FILE argument.  This will override the default
options in /etc/gnutls/pkcs11.conf

provider-opts option.
.....................

This is the "specify parameters for the pkcs #11 provider library"
option.  This option takes a ArgumentType.STRING argument.  This is a
PKCS#11 internal option used by few modules.  Mainly for testing PKCS#11
modules.

*NOTE**: THIS OPTION IS DEPRECATED*

batch option.
.............

This is the "disable all interaction with the tool" option.  In batch
mode there will be no prompts, all parameters need to be specified on
command line.

version option (-v).
....................

This is the "output version information and exit" option.  This option
takes a ArgumentType.KEYWORD argument.  Output version of program and
exit.  The default mode is 'v', a simple version.  The 'c' mode will
print copyright information and 'n' will print the full copyright
notice.

help option (-h).
.................

This is the "display extended usage information and exit" option.
Display usage information and exit.

more-help option (-!).
......................

This is the "extended usage information passed thru pager" option.  Pass
the extended usage information through a pager.

p11tool exit status
...................

One of the following exit values will be returned:
‘0 (EXIT_SUCCESS)’
     Successful program execution.
‘1 (EXIT_FAILURE)’
     The operation failed or the command syntax was not valid.

p11tool See Also
................

certtool (1)

p11tool Examples
................

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

