P11-KIT(8)

๐Ÿ’… p11-kit โ€” the p11-kit(8) manual, bestie edition

okay so picture this: you're deep in System Commands territory and you've got a p11-kit situation. don't panic, i got you. this is the whole page, every flag, every path, no crumbs left behind. ๐Ÿซถ


โœจ NAME โœจ

p11-kit โ€” the tool for doing stuff to your configured PKCS#11 modules. that's the whole vibe. ๐Ÿ’–


๐ŸŒˆ SYNOPSIS ๐ŸŒˆ

p11-kit list-modules

p11-kit list-tokens ...

p11-kit list-objects ...

p11-kit import-object ...

p11-kit export-object ...

p11-kit delete-object ...

p11-kit generate-keypair ...

p11-kit list-profiles ...

p11-kit add-profile ...

p11-kit delete-profile ...

p11-kit list-mechanisms ...

p11-kit print-config

p11-kit extract ...

p11-kit server ...

like. that's a lot of subcommands. main character energy fr fr. ๐Ÿ‘‘


๐Ÿฆ‹ DESCRIPTION ๐Ÿฆ‹

p11-kit is a command line tool, and what it does is perform operations on the PKCS#11 modules that are configured on your system. that's it. that's the whole job. โœจ

go look at all the sub commands down below โ€” but first, real quick, here are the global options that work anywhere:

  • -v, --verbose โ€” run in verbose mode, with debug output. it will NOT stop talking and honestly? sometimes you need that. ๐Ÿ—ฃ๏ธ
  • -q, --quiet โ€” run in quiet mode, without warning or failure messages. silence. peace. no notes. ๐Ÿคซ

๐ŸŒธ LIST MODULES ๐ŸŒธ

lists the PKCS#11 modules that are configured on your system.

$ p11-kit list-modules

it'll show you the modules, info about them, and the tokens that are chillin' inside those PKCS#11 modules. full tour. ๐Ÿ’…


๐ŸŽ€ LIST TOKENS ๐ŸŽ€

lists all the tokens available in the PKCS#11 modules that are configured on your system.

$ p11-kit list-tokens pkcs11:token

it grabs every token and shows off some of their common attributes. like a little token meet-and-greet.

this subcommand takes the following options:

  • --only-uris โ€” print only the matching token URIs. nothing else, just the URIs, that's the rule. โœจ
  • --provider=<module_path> โ€” load only the given PKCS#11 module instead of enumerating all the modules installed on the system. and lowkey important: if module_path is a relative path, the module gets loaded from the default module path. you can find out what that path is by running:
$ pkg-config p11-kit-1 --variable p11_module_path
/usr/lib64/pkcs11

๐Ÿ’œ LIST OBJECTS ๐Ÿ’œ

lists the objects that match a given PKCS#11 URI.

$ p11-kit list-objects pkcs11:object_on_token

it retrieves every object matching that PKCS#11 URI and shows some of their common attributes. and here's a cute detail: storage objects also get their PKCS#11 URI displayed. slay.

this subcommand takes the following options:

  • --login โ€” authenticate to the token before enumerating objects. the PIN value gets read from either the pin-value attribute in the URI, or from the terminal. pick your fighter. ๐Ÿ”
  • --provider=<module_path> โ€” load only the given PKCS#11 module instead of enumerating all the modules installed on the system. if module_path is a relative path, the module is loaded from the default module path. find that path with:
$ pkg-config p11-kit-1 --variable p11_module_path
/usr/lib64/pkcs11

๐Ÿ“ IMPORT OBJECT ๐Ÿ“

imports an object into a PKCS#11 token.

$ p11-kit import-object --file=file.pem [--label=label] [--id=object_id] pkcs11:token

so what it does: it takes either an X.509 certificate or a public key (in the form of a PEM file) and imports it into the first token matched by the given PKCS#11 URI. first match wins, no cap.

the following options are required:

  • --file=<file.pem> โ€” the file containing either an X.509 certificate or a public key, in PEM format. yeah you gotta have this one, it's not optional bestie.

this subcommand also accepts the following options:

  • --label=<label> โ€” assigns label to the imported object. ๐Ÿท๏ธ
  • --id=<object_id> โ€” assigns ID to the imported object. the ID should be specified in hexadecimal format without the 0x prefix. no 0x, we're serious.
  • --login โ€” authenticate to the token before enumerating objects. the PIN value is read from either the pin-value attribute in the URI or from the terminal.
  • --provider=<module_path> โ€” load only the given PKCS#11 module instead of enumerating modules installed on the system. if module_path is a relative path, the module is loaded from the default module path, which you can determine by running:
$ pkg-config p11-kit-1 --variable p11_module_path
/usr/lib64/pkcs11

๐Ÿงš EXPORT OBJECT ๐Ÿงš

exports the object matching a PKCS#11 URI.

$ p11-kit export-object pkcs11:object_on_token

it displays the PEM formatted contents of the first object matched by the given PKCS#11 URI. and important caveat, so listen up: the matched object has to either be an X.509 certificate or a public key. anything else and it's not happening. ๐Ÿ’€

this subcommand takes the following options:

  • --login โ€” authenticate to the token before enumerating objects. the PIN value is read from either the pin-value attribute in the URI or from the terminal.
  • --provider=<module_path> โ€” load only the given PKCS#11 module instead of enumerating modules installed on the system. if module_path is a relative path, the module is loaded from the default module path. you can determine that path by running:
$ pkg-config p11-kit-1 --variable p11_module_path
/usr/lib64/pkcs11

๐Ÿ’€ DELETE OBJECT ๐Ÿ’€

deletes the object matching a PKCS#11 URI.

$ p11-kit delete-object pkcs11:object_on_token
bestie. this one destroys the first object matched by the given PKCS#11 URI. gone. poof. no undo button. ๐Ÿ™ˆ

this subcommand takes the following options:

  • --login โ€” authenticate to the token before enumerating objects. the PIN value is read from either the pin-value attribute in the URI or from the terminal.
  • --provider=<module_path> โ€” load only the given PKCS#11 module instead of enumerating modules installed on the system. if module_path is a relative path, the module is loaded from the default module path. figure out that path with:
$ pkg-config p11-kit-1 --variable p11_module_path
/usr/lib64/pkcs11

๐Ÿ”‘ GENERATE KEY-PAIR ๐Ÿ”‘

generates a key-pair on a PKCS#11 token. ๐Ÿ’–โœจ

$ p11-kit generate-keypair --type=algorithm {--bits=n|--curve=name} [--label=label] [--id=object_id] pkcs11:token

it generates a private-public key-pair of the given type on the first token matched by the given PKCS#11 URI. and here's the tea: you should use this command together with the --type option and one of --bits or --curve. one. not both. we'll get there.

the following options are required:

  • --type=<algorithm> โ€” specify the type of keys to generate. supported values are rsa, ecdsa and eddsa. pick one bestie. ๐ŸŒˆ
  • --bits=<n> โ€” specify the number of bits for the key-pair generation. cannot be used together with the --curve option. ๐Ÿšซ
  • --curve=<name> โ€” specify an elliptic curve for the key-pair generation. supported values are secp256r1, secp384r1, secp521r1, ed25519 and ed448. cannot be used together with the --bits option. ๐Ÿšซ

this subcommand also accepts the following options:

  • --label=<label> โ€” assigns label to the generated key-pair objects. ๐Ÿท๏ธ
  • --id=<object_id> โ€” assigns ID to the generated key-pair objects. the ID should be specified in hexadecimal format without the 0x prefix. (again. NO 0x.)
  • --login โ€” authenticate to the token before enumerating objects. the PIN value is read from either the pin-value attribute in the URI or from the terminal.
  • --provider=<module_path> โ€” load only the given PKCS#11 module instead of enumerating modules installed on the system. if module_path is a relative path, the module is loaded from the default module path. determine that path by running:
$ pkg-config p11-kit-1 --variable p11_module_path
/usr/lib64/pkcs11

๐Ÿ‘‘ LIST PROFILES ๐Ÿ‘‘

lists the PKCS#11 profiles supported by the token.

$ p11-kit list-profiles pkcs11:token

it displays the profile IDs of the first token matched by the given PKCS#11 URI, in human-readable form. so you can actually read them. iconic.

this subcommand takes the following options:

  • --login โ€” authenticate to the token before enumerating objects. the PIN value is read from either the pin-value attribute in the URI or from the terminal.
  • --provider=<module_path> โ€” load only the given PKCS#11 module instead of enumerating modules installed on the system. if module_path is a relative path, the module is loaded from the default module path. get that path with:
$ pkg-config p11-kit-1 --variable p11_module_path
/usr/lib64/pkcs11

โญ ADD PROFILE โญ

adds a PKCS#11 profile to a token.

$ p11-kit add-profile --profile=profile pkcs11:token

it creates a new profile object with the given profile ID on the first token matched by the given PKCS#11 URI. and heads up: this command fails if the profile ID already exists on the token. no duplicates allowed, periodt. ๐Ÿ’…

the following options are required:

  • --profile=<profile> โ€” the profile ID to add. the value can either be numerical or textual. your call.

this subcommand also accepts the following options:

  • --login โ€” authenticate to the token before enumerating objects. the PIN value is read from either the pin-value attribute in the URI or from the terminal.
  • --provider=<module_path> โ€” load only the given PKCS#11 module instead of enumerating modules installed on the system. if module_path is a relative path, the module is loaded from the default module path. you can determine this path by running:
$ pkg-config p11-kit-1 --variable p11_module_path
/usr/lib64/pkcs11

๐ŸŽ€ DELETE PROFILE ๐ŸŽ€

deletes a PKCS#11 profile from a token.

$ p11-kit delete-profile --profile=profile pkcs11:token

it destroys all profile objects with the given profile ID from the first token matched by the given PKCS#11 URI. all of them. not one. all. ๐Ÿ˜ญ

the following options are required:

  • --profile=<profile> โ€” the profile ID to delete. the value can either be numerical or textual.

this subcommand also accepts the following options:

  • --login โ€” authenticate to the token before enumerating objects. the PIN value is read from either the pin-value attribute in the URI or from the terminal.
  • --provider=<module_path> โ€” load only the given PKCS#11 module instead of enumerating modules installed on the system. if module_path is a relative path, the module is loaded from the default module path. figure it out with:
$ pkg-config p11-kit-1 --variable p11_module_path
/usr/lib64/pkcs11

๐Ÿ”ฅ LIST MECHANISMS ๐Ÿ”ฅ

lists the PKCS#11 mechanisms supported by the token.

$ p11-kit list-mechanisms pkcs11:token

this lists all available mechanimsms for a PKCS#11 token. (yes, "mechanimsms". the original said it like that and honestly? i respect it. it's giving typo chic. ๐Ÿ’… we keep it exactly as-is because the facts don't change around here.)


prints the merged configuration.

$ p11-kit print-config

okay so here's the lore: p11-kit provides 3 levels of configuration โ€” system wide, per-module, and per-user. and at run-time, all 3 levels get merged into a single configuration. this command displays that merged configuration. so it's like the group chat where everyone's messages get combined into one chaotic beautiful thread. ๐Ÿซถ


๐Ÿฆ‹ EXTRACT ๐Ÿฆ‹

extracts certificates from configured PKCS#11 modules.

๐Ÿšจ okay so this operation has been moved to a separate command: trust extract. see trust(1) for more information. so if you came here looking for extract, go follow the breadcrumbs bestie. โœจ

โœจ SERVER โœจ

Okay bestie, this one is giving main character energy โ€” it literally runs a whole server process that exposes a PKCS#11 module remotely. ๐Ÿ’…

$ p11-kit server pkcs11:token1 pkcs11:token2 ...
$ p11-kit server --provider /path/to/pkcs11-module.so pkcs11:token1 pkcs11:token2 ...

So what it does: it launches a server that exposes the PKCS#11 tokens you named on a local socket. ๐Ÿซถ

Heads up: the tokens must belong to the same module. Like, non-negotiable, they're a package deal. ๐Ÿ˜ญ

To actually access that socket, you use the p11-kit-client.so module. That's the whole vibe.

And here's the cute part โ€” the server address and PID get printed out as a shell-script snippet that sets the appropriate environment variable, specifically:

  • P11_KIT_SERVER_ADDRESS
  • P11_KIT_SERVER_PID

So you can just source it and go, no cap. โœจ


๐Ÿฆ‹ EXTRACT TRUST ๐Ÿฆ‹

Extract standard trust information files. ๐ŸŽ€

Plot twist: this operation has been moved to a separate command, trust extract-compat. See trust(1) for more info. It's not living here anymore, it moved out and got its own place. ๐Ÿ 

๐Ÿ’œ REMOTE ๐Ÿ’œ

Run a PKCS#11 module remotely. Remote queen behavior, honestly.

$ p11-kit remote /path/to/pkcs11-module.so
$ p11-kit remote pkcs11:token1 pkcs11:token2 ...

Okay so real talk โ€” this is not meant to be run directly from a terminal. It's meant to go in a remote option in a pkcs11.conf(5) file. That's its natural habitat. ๐Ÿงš

What it does: it exposes the given PKCS#11 module or tokens over standard input and standard output.

Those two forms โ€” exposing a module, or exposing tokens โ€” are mutually exclusive. Pick one, bestie, you can't have both. ๐Ÿ™ˆ And if you go with the second form, the tokens must belong to the same module. Same rule as always, iconic consistency. ๐Ÿ‘‘

๐Ÿ’€ BUGS ๐Ÿ’€

Found a bug? Please send bug reports to either the distribution bug tracker or the upstream bug tracker at:

https://github.com/p11-glue/p11-kit/issues/

They wanna hear from you, fr fr. ๐Ÿ“


๐ŸŒˆ SEE ALSO ๐ŸŒˆ

Further details available in the p11-kit online documentation at:

https://p11-glue.github.io/p11-glue/p11-kit/manual/

And that's a wrap on the whole page, babe! ๐ŸŽ€ This one's from p11-kit itself, living in section P11-KIT(8) โ€” go forth and configure your PKCS#11 stuff with confidence. You ate this. ๐Ÿ’…โœจ๐Ÿซถ

๐Ÿ“ฆ where this page comes from