5

I have a YubiKey NEO which has a lot of amazing capabilities such as OTP, U2F, and PGP smart card for PGP/GPG and even SSH keys. One of the applications I've discovered recently for the device is a PIV applet which you can use to securely store a SSL certificate's private RSA key.

I find this pretty fascinating, as it makes it much more difficult without physical access to steal a SSL certificate.

Is it possible to use a smart card like this for a SSL server's private key? I've never seen configuration in Apache or nginx which would seem to indicate support for anything other than file-based SSL private keys.

Also, the demo given for the PIV applet shows how to create a local file-based private key and then send it to the smart card; is there a way to create the key securely on the card, so that it is never stored anywhere? I know I could just store it in a RAM disk/filesystem so that it's never written to disk, but is there a way to generate it on-device as is possible using OpenPGP for PGP keys?

1

I've never seen configuration in Apache or nginx which would seem to indicate support for anything other than file-based SSL private keys.

You are using the Yubikey as a Hardware Security Module (HSM). They key is stored on and never leaves the HSM and all encryption and decryption is done on the HSM. The Yubikey seems to fulfill such the requirements.

You might need to write your own PKCS#11 driver since there isn't one out there. For the server side, you would have to use mod_nss instead of mod_ssl. mod_nss allows you to use a custom PKCS#11 driver whereas mod_ssl uses the default openssl engine.

Compared with other purpose built HSMs, I am unsure of the stability of using the Yubikey as a HSM. This is because the main use case of a yubikey is for applications which require one-time access, e.g. authentication, encrypting an email and not for applications which require continuous access. A server under load might overwhelm the Yubikey and result in sluggish performance.

  • The key does not have to be stored in RAM on the computer. I can generate a PGP RSA key on the device which never leaves the device (is next to impossible to extract) and be able to sign and decrypt things by passing them through USB to the card, which does the signing/decryption and returns the result. And my YubiKey can definitely generate its own RSA key, so this doesn't seem to address the question. The link I've provided shows that much of what you deem impossible is possible. – Naftuli Kay Jan 1 '15 at 22:38
  • Thanks, it appears I underestimated the Yubikey. Edited my answer. – limbenjamin Jan 6 '15 at 12:36
  • 1
    Great, excellent edit! They do make a YubiKey HSM which is specifically for this, but it's good to know that in theory this would work :) – Naftuli Kay Jan 6 '15 at 19:32
0

Apache supports specifying the crypto device. The directive is called SSLCryptoDevice. You can specify

Pkcs11 as the device. Update: according to this answer it's not supported with mod_ssl. That answer suggests mod_nss, which supports it. According to https://mod.gnutls.org/ mod_gnutls also supports pkcs11.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.