TL;DR
YubiKey does not allow export of the private key, just the public cert. Instead I was demontrating (what I see as) a bug in YubiKey PIV Manager. It doesn't delete private keys properly.
Kudos Yubico
First off, although I am going to point out what I see as a bug in YubiKey,
I have to say, I was extremely impressed with the end-user support provided
by Yubico. And I quote:
we try to help everyone who submits a support case. even the white haired grandma next door
Properly Clearing the PIV Private Key
Since "Delete certificate" didn't delete the private key from the YubiKey,
re-loading the public key (which can be exported by YubiKey) resulted in a
functional PIV interface.
I was able to demonstrate two other methods that actually do clear
the private key:
Method 1: Load a Different Cert
I wasn't able to authenticate when I:
- Loaded my cert and exported a copy from yubikey (my-cert.crt)
- Loaded a different pfx/p12 file
- Loaded my-cert.crt
Method 1.1: Generate a Random Cert
It recently dawned on me that this is the simplest method. Just a couple of button pushes in the "YubiKey PIV Manager".
Method 2: "Reset" the PIV Module
I wasn't able to authenticate when I:
- Loaded my cert and exported a copy from yubikey (my-cert.crt)
"Reset" my yubikey PIV module
- I reset with this command:
yubico-piv-tool -areset
Strangely, I had lock out my PIN and PUK first. The easiest way to run the following commands and input bad inputs more than 3 times (In the case of PUK, you have to enter a valid new PIN and a bad PUK. Ugh.):
# Use to lock out PIN
yubico-piv-tool -averify-pin
# Use to lock out PUK
yubico-piv-tool -aunblock-pin
Is this a Bug?
Considering how painful the other two methods of resetting the private key are,
"Delete certificate" is by far the easiest method of "wiping" your cert
from the device. Nothing suggests the other two methods are necessary.
Yubico suggested that "reset" was the recommended action before passing the
device off to another user.
Personally, I see this as a bug, but I don't know if Yubico is sold yet.
Here's the bad scenario I envision:
- I load my public/private key pair
- I delete my public key from the device (but silently leave the private key intact)
- I reset the admin PIN
- I hand the device over to someone else to use
- The second person uploads my public cert and gets a working copy of my public/private pair