You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Support OpenSSL keystores. Formatting is identical to our normal private
key format (keyname:private-key-here) but OpenSSL will parse it as a URI
(e.g. keyname:scheme:private-key-here).
Add --key-uri in addition to --key-file that automatically enables the
'keystore' feature and performs the signature, without the need to put
the private key in a file.
This allows using PEM-formatted private keys if desired
(e.g. mykey:file:/etc/nix/mykey.pem), in addition to PKCS#11
(e.g. mykey:pkcs11:id=%01;object=mykey;token=nixpkcs;type=private?foo).
Tested using [nixpkcs](https://github.com/numinit/nixpkcs) by injecting
an OpenSSL config into Nix that adds support for the PKCS#11 scheme with
pkcs11-provider.
Signing:
```
$ nix-shell -p openssl pkcs11-provider yubico-piv-tool
$ openssl ecparam -genkey -name secp384r1 -noout -out p384.pem
$ echo "p384:file:$(realpath p384.pem)" > p384.uri
$ ./src/nix/nix store sign \
/nix/store/icq1cx1x7fjxim84sfanrv1j3vgb1qwp-pkcs11-provider-1.1 \
--key-file ./p384.key \
--extra-experimental-features 'cnsa keystore'
$ nixpkcs-uri ca
pkcs11:id=%02;token=YubiKey%20PIV%20%236108039;type=private?\
module-path=%2Fnix%2Fstore%2Fxcmf5v8y8vn5g5krsr2cyxp7hjmjgijc-yubico-piv-tool-2.7.2%2Flib%2Flibykcs11.so&\
pin-source=file%3A%2Fetc%2Fnixpkcs%2Fyubikeys%2F6108039%2Fuser.pin
$ # generated with nixpkcs:
$ export OPENSSL_CONF='/nix/store/gq3izqn2wflfr5cxan2nqz0nrww415h3-openssl-with-pkcs11.openssl.cnf'
$ ./src/nix/nix store sign \
/nix/store/icq1cx1x7fjxim84sfanrv1j3vgb1qwp-pkcs11-provider-1.1 \
--key-uri yubikey-6108039:$(nixpkcs-uri ca) \
--extra-experimental-features cnsa
```
Verifying:
```
$ nix path-info --json --json-format 2 \
/nix/store/icq1cx1x7fjxim84sfanrv1j3vgb1qwp-pkcs11-provider-1.1
{
"info": {
"icq1cx1x7fjxim84sfanrv1j3vgb1qwp-pkcs11-provider-1.1": {
"ca": null,
"deriver": "1lparccpa6kjh2sc7n4hkd3vkr4n1c1h-pkcs11-provider-1.1.drv",
"narHash": "sha256-iS7ETDBufxea39YxmAWeJ67NHcSuPAvONWe462pQpAk=",
"narSize": 613744,
"references": [
"1xj3zlgsv40gbhc0fxm0fphxsd4b7l7k-p11-kit-0.25.9",
"daamdpmaz2vjvna55ccrc30qw3qb8h6d-glibc-2.40-66",
"llswcygvgv9x2sa3z6j7i0g5iqqmn5gn-openssl-3.6.0"
],
"registrationTime": 1779338946,
"signatures": [
"cache.nixos.org-1:mULTk4OTkR3WVcGF1ClS3kJdQcRMlgbjy7GhH0inFKe9qi4Fw9kVDb/3SaYpbXTgQzfpQJypI91Jx9lq5JhwBg==",
"p384:MGUCMQDXldyCdoiVKOp/Mqf1cDjZ1lmmNgmnedh6eJFeHFtMgck0EjsfFXnWe/TMH+Rc1boCMDhvOj9n8yUkkketqM1thIE6fqiFp5lUYZ3KEZ2l8B2q4Sm1V/3ASeVYzBJ7y5hLeQ==",
"yubikey-6108039:MGUCMQCzcVYwFttNbQxcxflbIsmEcAEPCI2fiNZEissy0razpmZDMT0MdjuIsN8HYyFe7f8CMFVxVfVn0kqXE3C01RWIVLy5BslkFX3xYTI6w56ooSWo4jRZCbdVXoKWNO5YVJcvYg=="
],
"storeDir": "/nix/store",
"ultimate": false,
"version": 2
}
},
"storeDir": "/nix/store",
"version": 2
}
```
0 commit comments