Add kx509 client and revamp kx509 service
authorNicolas Williams <nico@twosigma.com>
Tue, 18 Jun 2019 00:34:21 +0000 (19:34 -0500)
committerNicolas Williams <nico@twosigma.com>
Wed, 9 Oct 2019 02:26:50 +0000 (21:26 -0500)
commit6a7e7eace67cb3021bcd6dce3a2ff80e6dff76d1
tree0ca26679b6f3cb87b664f63a4d7b0432faab344c
parent78cb995e6e6d744f3b8f036f4e62e7ccc693454e
Add kx509 client and revamp kx509 service

This commit adds support for kx509 in libkrb5, and revamps the KDC's
kx509 service (fixing bugs, adding features).

Of note is that kx509 is attempted optimistically by the client, with
the certificate and private key stored in the ccache, and optionally in
an external PEM or DER file.

NOTE: We do not optimistically use kx509 in krb5_cc_store_cred() if the
      ccache is a MEMORY ccache so we don't generate a key when
      accepting a GSS context with a delegated credential.

kx509 protocol issues to be fixed in an upcoming commit:

 - no proof of possession (this is mostly not too bad, but we'll want to
   fix it by using CSRs)
 - no algorithm agility (only plain RSA is supported)
 - very limited (no way to request any options in regards to the
   requested cert)
 - error codes are not very useful

Things we're adding in this commit:

 - libkrb5 kx509 client
 - automatic kx509 usage hooked in via krb5_cc_store_cred() of start TGT
 - per-realm templates on the KDC side
 - per-realm issuer certificates
 - send error messages on the KDC side
   (this is essential to avoid client-side timeouts on error)
 - authenticate as many error messages
 - add a protocol probe feature so we can avoid generating a
   keypair if the service is not enabled
   (once we add support for ECC algorithms we won't need this
    anymore; the issue is that RSA keygen is slow)
 - support for different types of client principals, not just username:

    - host-based service and domain-based service, each with its own
      template set per-{realm, service} or per-service

   (the idea is to support issuance of server certificates too, not
    just client/user certs)
 - more complete support for SAN types
 - tests (including that PKINIT->kx509->PKINIT works, which makes it
   possible to have "delegation" of PKIX credentials by just delegating
   Kerberos credentials)
 - document the protocol in lib/krb5/kx509.c

Future work:

 - add option for longer-ticket-lifetime service certs
 - add support for ECDSA, and some day for ed25519 and ed448
 - reuse private key when running kinit
   (this will require rethinking how we trigger optimistic kx509
    usage)
 - HDB lookup for:
    - optional revocation check (not strictly necessary)
    - adding to certificates those SANs listed in HDB
       - hostname aliases (dNSName SANs)
       - rfc822Name (email)
       - XMPP SANs
       - id-pkinit-san (a user could have aliases too)
 - support username wild-card A RRs, ala OSKT/krb5_admin
    i.e., if a host/f.q.d.n principal asks for a certificate for
    some service at some-label.f.q.d.n, then issue it
   (this is not needed at OSKT sites because OSKT already
    supports keying such service principals, which means kx509
    will issue certificates for them, however, it would be nice
    to be able to have this independent of OSKT)
   (a better way to do this would be to integrate more of OSKT
    into Heimdal proper)
 - a kx509 command, or heimtools kx509 subcommand for explicitly
   attempting use of the kx509 protocol (as opposed to implicit, as is
   done in kinit via krb5_cc_store_cred() magic right now)

Issues:

 - optimistically trying kx509 on start realm TGT store -> timeout issues!
    - newer KDCs will return errors because of this commit; older ones
      will not, which causes timouts
    - need a separate timeout setting for kx509 for optimistic case
    - need a [realm] config item and DNS SRV RR lookup for whether a
      realm is expected to support kx509 service
23 files changed:
doc/standardisation/rfc6717.txt [new file with mode: 0644]
kdc/default_config.c
kdc/kx509.c
kdc/process.c
kuser/Makefile.am
kuser/NTMakefile
kuser/heimtools-commands.in
kuser/klist.1
kuser/klist.c
lib/asn1/kx509.asn1
lib/krb5/Makefile.am
lib/krb5/NTMakefile
lib/krb5/cache.c
lib/krb5/krb5.conf.5
lib/krb5/krb5.h
lib/krb5/kx509.c [new file with mode: 0644]
lib/krb5/kx509_err.et [new file with mode: 0644]
lib/krb5/libkrb5-exports.def.in
lib/krb5/version-script.map
tests/gss/krb5.conf.in
tests/kdc/Makefile.am
tests/kdc/check-pkinit.in
tests/kdc/krb5-pkinit.conf.in