notary: yubikey HSM driver not loading on OSX 10.11.6 (15G1004)
Hello, I’m trying to test out notary with the Yubikey 4 support, and having some troubles getting it to work.
I’m using notary version:
notary
Version: 0.4.2
Git commit: c8aa8cf
When running notary init, it logs an error loading /usr/local/lib/libykcs11.dylib:
notary init example.com/collection -D -s http://notary-server:8080
DEBU[0000] Using the following trust directory: /Users/exampleuser/.notary
DEBU[0000] Trusting 1 certs
ERRO[0000] could not reach http://notary-server:8080: Get http://notary-server:8080/v2/: dial tcp 192.168.64.2:8080: getsockopt: connection refused
INFO[0000] continuing in offline mode
DEBU[0000] No yubikey found, using alternative key storage: found library /usr/local/lib/libykcs11.dylib, but initialize error pkcs11: 0x6: CKR_FUNCTION_FAILED
DEBU[0000] No yubikey found, using alternative key storage: found library /usr/local/lib/libykcs11.dylib, but initialize error pkcs11: 0x6: CKR_FUNCTION_FAILED
No root keys found. Generating a new root key...
DEBU[0000] generated ECDSA key with keyID: ad74b12de90f93ed5acad8daded968e5f4f95509906728cfb24bbc3b8b01c156
DEBU[0000] generated new ecdsa key for role: root and keyID: ad74b12de90f93ed5acad8daded968e5f4f95509906728cfb24bbc3b8b01c156
DEBU[0000] No yubikey found, using alternative key storage: found library /usr/local/lib/libykcs11.dylib, but initialize error pkcs11: 0x6: CKR_FUNCTION_FAILED
You are about to create a new root signing key passphrase. This passphrase
will be used to protect the most sensitive key in your signing system. Please
choose a long, complex passphrase and be careful to keep the password and the
key file itself secure and backed up. It is highly recommended that you use a
password manager to generate the passphrase and keep it safe. There will be no
way to recover this key. You can find the key in your config directory.
Enter passphrase for new root key with ID ad74b12:
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 21 (11 by maintainers)
Update:
So, on a hunch after reading some bug reports about problems with
scdaemonYubikey access & PCSC library access randomly stopping I decided to test something out:gpg2 --card-statusis able to contact Yubikey & list keysscdaemonprocesses (which appear to get started bygpg-agenton-demand automatically)notary init -DcommandResults:
Observations:
It looks like the
scdaemonprocess started bygpg-agentlocks up the Yubikey for exclusive access, which preventsnotaryfrom accessing the key. Killingscdaemonworks for a brief period of time until the nextgpgoperation that needs to access the key & automatically starts up scdaemon again, blocking access to the key from anything else.Additionally, there are bugs in the way
scdaemonhandles the Yubikey 4 on OSX, causing the key to become inaccessible even to the samescdaemonandgpg-agentprocesses that were able to access it before. This issue begins to happen after some period of time in the order of 30-mins to1-2(unknown?) hours of time.scdaemon.logfile shows errors:pcsc_connect failed: sharing violation (0x8010000b),new_reader_slot: out of slots.Killing
scdaemontemporarily fixed the access issue by GPG, thengpg2 --card-statusworked. Killingscdaemonagain finally allowednotary init -Dto work!scdaemon.log:There is an unaccepted patch which some say alleviates this issue. However, it was not accepted by official upstream GnuPG, and the bug was closed as
wontfix. The reasoning was as follows:There are reported to be other workarounds which require disabling OSX built-in
ifdhandler(sudo launchctl unload /System/Library/LaunchDaemons/com.apple.ifdreader.plist). GPGTools recommended to this user to try the latest nightly build as of Jan 26th 2015, and it was accepted that it was fixed.However, because I’m using
gpg21from Homebrew forgpg-agentsocket forwarding support (brew tap homebrew/versions && brew install gnupg21), I cannot benefit from the fixes in GPGTools. GPGTools has stated that they are considering switch tognupg 2.1, but not in the near future. There is a bug ticket for tracking GnuPG 2.1 support in GPGTools / MacGPG, as mentioned in this official comment.TLDR;
There are bugs with Yubikey OpenPGP access in upstream GPG
2.0.xAND2.1.xseries releases on at least OSX versions:10.10(Yosemite)10.11(El Capitan)10.12(Sierra) GPGTools not compatible with this release yet!scdaemonis launched to access the Yubikey smart card, and then begins to fail to access it after a period of time.scdaemonalso locks up access to the card while it is running by other applications including at least:notaryGNUPG accepted workaround:
kill $(pidof scdaemon)@riyazdf CCID mode confirmed. The Yubikey is showing 0x0407 which is the “everything enabled” mode.