From c227c812b544dc668d7f3e74cfdee5ba0df125dc Mon Sep 17 00:00:00 2001 From: Nicolas Stalder Date: Sun, 10 Jan 2021 16:58:02 +0100 Subject: [PATCH] Document how to setup test env --- README.md | 5 +++++ examples/lookup.rs | 12 ++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 2b84e11..b289175 100644 --- a/README.md +++ b/README.md @@ -6,3 +6,8 @@ One way to generate URIs to feed into this library is the `p11tool` in GnuTLS. Running `p11tool --list-tokens` returns the URIs for all available tokens. Running `p11tool --list-all ` then lists all the objects in that token. For private keys, use `GNUTLS_PIN= p11tool --login --list-all `. + +One way to create keypairs to use is with softhsm-util and pkcs11-tool: +``` +softhsm2-util --init-token --free --label my-ca --pin 1234 --so-pin 1234 +pkcs11-tool --module /usr/lib/libsofthsm2.so --token my-ca --login --pin 1234 --keypairgen --label my-signing-key --key-type RSA:2048 diff --git a/examples/lookup.rs b/examples/lookup.rs index 364ae53..dcef4c1 100644 --- a/examples/lookup.rs +++ b/examples/lookup.rs @@ -12,20 +12,20 @@ fn main() { fn try_main() -> anyhow::Result<()> { let _uri_str = r"pkcs11: type=private; - token=lpc55-2ac0c213b4903b76; - object=lpc55-2ac0c213b4903b76%20@%202021-01-08T20:41:24 + token=my-ca; + object=my-signing-key ?pin-source=file:pin.txt &module-path=/usr/lib/libsofthsm2.so"; let _uri_str = r"pkcs11: type=private; - token=lpc55-2ac0c213b4903b76; - object=lpc55-2ac0c213b4903b76%20@%202021-01-08T20:41:24 + token=my-ca; + object=my-signing-key ?pin-source=env:PIN &module-path=/usr/lib/libsofthsm2.so"; let _uri_str = r"pkcs11: type=private; - token=lpc55-2ac0c213b4903b76; - object=lpc55-2ac0c213b4903b76%20@%202021-01-08T20:41:24 + token=my-ca; + object=my-signing-key ?pin-value=1234 &module-path=/usr/lib/libsofthsm2.so"; let uri = Pkcs11Uri::try_from(_uri_str)?;