Getting YubiKey working with Docker Content Trust on OS X

Getting YubiKey working with Docker Content Trust on OS X

This wasn’t as straightforward as I would’ve liked, so I’m documenting this here.

First, some super-useful sources:

I only figured this out because the folks above did most of the work!

Preparation…

Install notary

Just a matter of grabbing the latest from https://github.com/docker/notary/releases and putting the notary binary in the path somewhere (like ~/bin in my case).

Install the YubiKey PIV shared libraries

$ curl -OL https://developers.yubico.com/yubico-piv-tool/Releases/yubico-piv-tool-1.4.3-mac.zip
...
$ unzip yubico-piv-tool-1.4.3-mac.zip
$ mkdir -p /usr/local/docker/lib
$ cp -av lib/ /usr/local/docker/lib
$ DOCKER_CONTENT_TRUST=1 docker -D pull alpine
Using default tag: latest
DEBU[0000] reading certificate directory: /Users/myuser/.docker/tls/notary.docker.io
DEBU[0000] Initialized PKCS11 library /usr/local/docker/lib/libykcs11.dylib and started HSM session
...

Configuration…

Ok now we’re ready to create a key:

$ notary key list
ROLE   GUN    KEY ID        LOCATION
------------------------------------------
root         deadbeef....   file (/Users/myuser/.notary/private)  
root         deadbeef....   yubikey    
$ notary key export > /Volumes/SomeUSBStick/notary.key
...
$ rm ~/.notary/private/root_keys/deadbeef....key

Signing on push

And now for the magic:

$ export DOCKER_CONTENT_TRUST=1
$ docker build -t hairyhenderson/dct-test:latest
...
$ docker push hairyhenderson/dct-test:latest
The push refers to a repository [docker.io/hairyhenderson/dct-test]
e520aba5adf5: Layer already exists
917d421641b4: Layer already exists
e9d17ff7ca16: Layer already exists
63bcbfab7dc5: Layer already exists
af21bd4b5bb1: Layer already exists
4b0b3b9ff599: Layer already exists
d1e800db26c7: Layer already exists
42755cf4ee95: Layer already exists
latest: digest: sha256:deadbeef25599d9a37bd452ba6918ac198693fe4b9f9822d0a4bf54735469f04 size: 1974
Signing and pushing trust metadata
Please touch the attached Yubikey to perform signing.
Enter passphrase for new repository key with ID 7ff917d (docker.io/hairyhenderson/dct-test):
Repeat passphrase for new repository key with ID 7ff917d (docker.io/hairyhenderson/dct-test):
Please touch the attached Yubikey to perform signing.
Finished initializing "docker.io/hairyhenderson/dct-test"
Successfully signed "docker.io/hairyhenderson/dct-test":latest

This is as far as I’ve gotten… Maybe more to come later!

comments powered by Disqus