PackagingDrafts/PKCS11

From FedoraProject

Jump to: navigation, search

Contents

Background

PKCS#11

PKCS#11 is the API standard for cryptographic tokens. It covers both hardware crypto devices and software storage like the NSS database that remembers which web site certificates you've accepted. It provides an object store for keys and certificates — and for keys it can perform crypto operations for you using the key instead of just handing out the private key data willy-nilly.

It's very useful to be able to import keys into a PKCS#11 token and use them from there — even if it's just a software token like the one provided by gnome-keyring — instead of just having them stored in a file in a user's home directory. That's exactly what you're doing when you import a certificate into something like Firefox, Thunderbird or Evolution. There are plans to make NetworkManager always behave this way too: https://wiki.gnome.org/Projects/NetworkManager/PKCS11

Usability

The problem is that in most cases PKCS#11 is much too hard to set up and use. You have to explicitly configure each application to know where to load the PKCS#11 token, and there are numerous different ways of specifying which certificate from the token you want to use.

By consistently using p11-kit for token configuration, and PKCS#11 URIs for specifying objects, we make things a lot simpler for Fedora users. If I want to use a certain certificate from my Yubikey, I should be able to use the URI pkcs11:manufacturer=piv_II;id=%01 consistently in *all* applications within Fedora and expect it to work.

Currently, there are many different ways to tell each application how to find the certificate. With OpenVPN it's: --pkcs11-providers=/usr/lib64/pkcs11/opensc-pkcs11.so --pkcs11-id=piv_II/PKCS\x2315\x20emulated/108421384210c3f5/PIV_II\x20\x28PIV\x20Card\x20Holder\x20pin\x29/01

With wpa_supplicant it's different again, as shown at http://w1.fi/cgit/hostap/plain/wpa_supplicant/examples/openCryptoki.conf

All of these should just take a simple PKCS#11 URI and Just Work™.

Expectations

Obviously, packagers are not always expected to be proficient coders in the langage their packages are written in. We don't necessarily expect packagers to fix software for themselves, although it's great when they can.

However, it is certainly within the purview of a packager to work with the upstream developers and ensure that the appropriate features are requested and given due consideration.

Most importantly, it is often the case that software can be built with more than one crypto library, and the feature set available will depend on that choice. For example the OpenConnect VPN client will comply with all of the above requirements when built with GnuTLS, but not when built with OpenSSL. This much certainly is within the direct control of the packager. Likewise, sometimes all that is required is to configure a piece of software to use p11-kit-proxy.so as its PKCS#11 provider module by default. Again, that's certainly something a packager can do.

Packagers

What we ask of packagers is this:

  • Check if your package can use SSL client certificates for authentication. If it can't, you have nothing to do.
  • If it can use SSL client certificates, check and see if it can use PKCS#11. (See the help section below).
  • If the package can support PKCS#11, please make sure you build it with that support enabled, and configure it to use p11-kit-proxy.so as its default PKCS#11 provider when none is specified/overridden by the user.
  • If the package can't support PKCS#11, please file a feature request with the upstream developers to fix that.

Help

Various applications might support PKCS#11 tokens differently, and it might even differ according to which crypto library you choose to build against.

If you use GnuTLS, it's quite likely that it'll automatically just Do The Right Thing, and happily take a PKCS#11 URI in place of a filename for certificates and keys. GnuTLS is probably the best choice if your package supports it, unless your package has specific requirements.

If you use OpenSSL, it has no native PKCS#11 support. But your package might support being built with the additional pkcs11-helper or libp11 libraries, or using engine_pkcs11. If not, please talk to the upstream developers about supporting the ENGINE. It's relatively simple to add. Ask dwmw2 and he may be able to provide patches for you.

If you use NSS, it might not accept URIs but if it's a graphical program that might not matter. You can probably just rely on NSS to be fixed (bug 1173577). Until that bug is fixed, it's probably best not to choose NSS. If your package can build against another crypto library, do that.

  • [FIXME] Add (link to) instruction on how to import a cert from a file into a PKCS#11 token like gnome-keyring, find the URI for it, and then test that an application accepts that URI in place of the filename.

Guidelines Summary

Client applications

  • Packages which use SSL certificates/keys from a file or elsewhere SHOULD also support using certs/keys from PKCS#11 tokens.
  • Packages which can use PKCS#11 tokens SHOULD automatically use the tokens which are present in the system's p11-kit configuration, rather than needing to have a PKCS#11 provider explicitly specified.

PKCS#11 Providers

  • Packages providing PKCS#11 modules SHOULD also provide a corresponding module file in the directory specified by pkg-config p11-kit-1 --variable p11_module_configs (currently /usr/share/p11-kit/modules) so that the new module is automatically visible in well-behaved applications.

Rationale