Commit Graph

28968 Commits

Author SHA1 Message Date
Roland C. Dowdeswell
3b828e23e7 Don't build the docs on appveyor 2019-11-20 18:14:44 -05:00
Roland C. Dowdeswell
69dd82d33e Stop stuttering in libkrb5-exports.def.in 2019-11-20 18:14:44 -05:00
Roland C. Dowdeswell
cd297eb462 Declare variables at the beginning of a block.
Looks like this fixes the Appveyor build.
2019-11-20 18:14:44 -05:00
Roland C. Dowdeswell
01126367d3 w32-check-exported-symbols: Eliminate perl warning
This will become fatal in the next version of Perl, so we need
to eliminate it now.
2019-11-20 18:14:44 -05:00
Roland C. Dowdeswell
06f3507c77 Update .gitignore to catch more test remains 2019-11-20 18:14:44 -05:00
Nicolas Williams
4500a14f95 hx509: Show query expression parse errors 2019-11-19 23:00:41 -06:00
Nicolas Williams
a40d4056bd asn1: Add der_find_or_parse_heim_oid() 2019-11-19 23:00:41 -06:00
Nicolas Williams
944eae82cf asn1: Remove alias of id-kp-clientAuth 2019-11-19 23:00:41 -06:00
Nicolas Williams
c1841f2f67 gssapi: Import elric1's gss-token 2019-11-19 23:00:41 -06:00
Nicolas Williams
56c5f5909e roken: Add rkvis program for test scripts
This will help programs that need to URL-escape strings.

Also, this changes `do_hvis()` to not fallback on `do_svis()` for chars in
`extra` -- that `do_hvis()` was doing that seems like an oversight.  Christos
Zoulas, of NetBSD, agrees.  `do_hvis()` still falls back on `do_svis()` for
characters not in the RFC 1808 / 3986 to-be-escaped set *and* characters not in
the `extra` set -- that much seems to have been the intent.
2019-11-19 22:33:20 -06:00
Nicolas Williams
4981cfc420 roken: base64: set errno on decode errors 2019-11-18 17:28:32 -06:00
Roland C. Dowdeswell
a8b749685c include <sys/exec_elf.h> if it's available.
This fixes the auxval logic on NetBSD.
2019-11-18 14:20:19 -06:00
Nicolas Williams
ba5bb07495 krb5: disable automatic kx509 by default 2019-11-13 18:42:28 -06:00
Roland C. Dowdeswell
84ffa22c93 Add an "EFILE:" target for logging.
This target will write to a file IFF it exists.
2019-11-10 17:47:36 -05:00
Roland C. Dowdeswell
e44c680d8e Make logging path definitions subject to token expansion. 2019-11-10 17:47:36 -05:00
Roland C. Dowdeswell
0c869176f4 Define a token expansion for %{strftime:<string>}. 2019-11-10 17:47:36 -05:00
Roland C. Dowdeswell
3c7da79838 derived keys: ensure that princ is correct
We copy the princ in the hdb_entry so that if it is later used, it
will reflect what we want.
2019-11-07 20:11:55 -05:00
Nicolas Williams
a2650ef20b kx509: Fix uninitalized ret var use 2019-11-06 19:51:21 -06:00
Nicolas Williams
fce3f16859 hx509: Add hx509_ca_tbs_get_name()
This is so we can check if a TBS gets an empty subject name, then refuse
to issue the certificate if it doesn't also have at least one SAN.
2019-11-06 19:51:21 -06:00
Viktor Dukhovni
12826c9586 Handle partial writes on non-blocking sockets
Now that we're using krb5_net_write() with non-blocking sockets in
ipropd_master, we MUST correctly account for partial writes.

Therefore, roken net_write() called from krb5_net_write() now
returns the number of bytes written when the socket error was
EWOULDBLOCK (or EAGAIN).

Also, fix potential issue on Windows, where errno was used instead
of rk_SOCKET_ERRNO whether or not we used _write() or send().
2019-11-06 20:27:58 -05:00
Nicolas Williams
9ca5d710f9 hx509: fix hx509_request_get_eku() 2019-11-04 14:11:40 -06:00
Jeffrey Altman
efb27f15ac Windows: update default timestamping service
The Verisign and Symantec timestamping services have been shutdown.
Switch to the Digicert service which replaced the Symantec services
as of 31 Oct 2019.

  http://timestamp.digicert.com

Change-Id: I365e6c3698b8fc99b18e8d1e5a54ce3519f3c5eb
2019-11-02 21:14:00 -04:00
Nicolas Williams
0cc708ba36 kx509: add time-to-live for kx509 -t option
It's useful to check for having so many seconds left in useful
credential lifetime.
2019-11-02 18:49:42 -05:00
Nicolas Williams
94bf464f8d krb5: Add krb5_ticket_get_times() 2019-11-02 18:49:42 -05:00
Nicolas Williams
66cde3e580 hx509: Fix hx509_request_get_exts() 2019-11-02 18:49:42 -05:00
Nicolas Williams
35c91324ed hx509: Add hx509_get_instance() 2019-11-02 18:49:42 -05:00
Nicolas Williams
427751a204 hxtool: Add "acert" (assert cert contents) command
This will prove useful in testing kx509.
2019-11-02 18:49:42 -05:00
Nicolas Williams
6612090ba0 hx509: Export missing symbols 2019-11-02 18:49:42 -05:00
Nicolas Williams
ddbc36d86b hx509: Store priv keys first in PEM stores
Most consumers of PEM files don't care about the order in which private
keys and certificates are stored.  However, Postfix does care when
multiple EE certs (and chains) are stored in a file, in which case it
requires that private keys come before their certificates.
2019-11-02 18:49:42 -05:00
Nicolas Williams
7dc134e410 krb5: Move krb5_plugin_load_t typedef to header 2019-11-02 18:49:42 -05:00
Nicolas Williams
ec858b3a46 ipc: Get socket dir via secure_getenv()
Using /var/run means needing privilege to run.
2019-11-02 18:49:42 -05:00
Nicolas Williams
b54107ee2b asn1: Add more EKU OIDs from RFC7299, OpenSSL 2019-11-02 18:37:13 -05:00
Nicolas Williams
ed1f900cfb asn1: Add some missing OIDs from RFC5280 2019-11-02 18:37:13 -05:00
Nicolas Williams
db35aeb5be asn1: Fix OID resolution bug 2019-11-02 18:37:13 -05:00
Nicolas Williams
f717c7344b gss: Fix double-free in acquire_from 2019-10-30 21:18:08 -05:00
Roland C. Dowdeswell
ba65039586 Lightly document derived key namespaces 2019-10-30 16:31:51 -05:00
Viktor Dukhovni
5bbe7c8dc6 Implement forwarding of leaf TGTs to selected realms.
Refactor and enhance TGT forwarding to allow forwarding of leaf
(destination) TGTs for selected destination realms.

Enhance kinit(1) to renew non-origin realm tickets

Document delegate-destination-tgt

Use the newly implemented _krb5_mk_1cred().
2019-10-30 16:20:58 -05:00
Roland C. Dowdeswell
d81118cc1f Implement krb5_mk_{1,n}cred 2019-10-30 16:20:58 -05:00
Roland C. Dowdeswell
2e0366b7a0 Teach make-proto.pl about #define \-continuation. 2019-10-30 16:20:58 -05:00
Roland C. Dowdeswell
a86e1076a0 Ignore tags files and *_asn1_oid.x 2019-10-30 18:16:34 +00:00
Václav Chlumský
1522ec5171 _gsskrb5_acquire_cred_from leaks context 2019-10-29 14:19:01 +00:00
Roland C. Dowdeswell
c7d4682aed Define log levels in docs and change default to 0-3.
We define the meaning of the various log levels in the man page
for krb5_openlog(3).  If logging configured and levels are not
specified, we change the default levels to 0-3 which should exclude
debugging messages which are generally only desired in exceptional
circumstances.

We also go through the KDC and adjust the levels to be appropriate.
2019-10-21 13:43:01 +01:00
Roland C. Dowdeswell
aa5c525e71 Implement [kdc] derived_keys_maxdots 2019-10-18 14:47:33 -04:00
Nicolas Williams
dfada0ccad kx509: Add CSR support
This commit adds support for proof of posession to the kx509 protocol by
using PKCS#10 CSRs.

This allows conveyance of extReq CSR attributes requesting desired
Certificate Extensions.
2019-10-09 20:53:30 -05:00
Nicolas Williams
c838abdf1a ipc: fix warning 2019-10-09 20:53:30 -05:00
Nicolas Williams
6f9eb81243 krb5: copy AD from auth_context to Authenticator
If the caller provides authz data in the auth context, then we should
copy it to the Authenticator when making an AP-REQ!
2019-10-08 22:20:40 -05:00
Nicolas Williams
8af2d79d35 hx509: Add missing CSR extension request support
This is necessary in order to add proper support for CSRs in kx509,
where the KDC can examine all requested KUs/EKUs/SANs, check
authorization, and issue a certificate with all those extensions if
authorized.

This is the convention used by OpenSSL, of encoding all the KU, EKUs,
and SANs being requested as Extensions as they would appear in the
TBSCertificate, then putting those in as a single Attribute in the CSR's
Attributes list with attribute OID {id-pkcs-9, 14}.

 - expose all hx509_request_*() functions
 - finish support in hx509_request_parse*() for KU, EKU, and SAN CSR
   attributes
 - finish support in hx509_request_to_pkcs10() for encoding all
   requested KU, EKU, and SAN extensions as a CSR extReq (extension request)
 - add hx509_request_add_*() support for:
    - id-pkinit-san and ms-upn-pkinit-san
    - XMPP (Jabber) SAN
    - registeredID (useless but trivial)
 - add hxtool request-create options for all supported SANs
 - add hxtool request-create options for KeyUsage
 - add hxtool request-create options for ExtKeyUsage
 - add hxtool request-print support for all these things
 - fix bugs in existing id-pkinit-san handling

Possible future improvements

 - add HX509_TRACE env var and support (it would be nice to be able to
   observe why some certificate is rejected, or not matched in a query)
 - add testing that CSR creating and printing round-trip for all KUs,
   EKUs, and SANs
   (probably in tests/kdc/check-pkinit.in)
 - add testing that OpenSSL can print a CSR made by hxtool and
   vice-versa
 - hxtool ca: add KU sanity checking (via hx509_ca_sign() and/or friends)
   (don't allow encrypt for signing-only algs)
   (don't allow encrypt for RSA at all, or for RSA with small e exponents)
 - hxtool request-print: warn about all unknown attributes and
   extensions
 - hxtool ca: MAYBE add support for adding requested extensions from the
   --req=CSR
   ("Maybe" because CA operators should really verify and authorize all
    requested attributes, and should acknowledge that they have, and the
    simplest way to do this is to make them add all the corresponding
    CLI arguments to the hxtool ca command, but too, that is
    error-prone, thus it's not clear yet which approach is best.
    Perhaps interactively prompt for yes/no for each attribute.)
 - add additional SAN types:
    - iPAddress                 (useless?)
    - dNSSrv                    (useful!)
    - directoryName             (useless, but trivial)
    - uniformResourceIdentifier (useful)
 - it would be nice if the ASN.1 compiler could generate print
   functions..., and/or even better, to-JSON functions
 - it would be nice if we had a known-OID db, including the names of the
   types they refer to in certificate extensions, otherName SANs and CSR
   attributes, then we could generate a CSR and certificate printer for
   all known options even when they are not supported by the rest of
   Heimdal
    - and we could also get friendly names for OIDs, and we could
      resolve their arc names
    - longer term, we could also stand to add some ASN.1 information
      object system functionality, just enough to make
      lib/hx509/asn1_print awesome by being able to automatically decode
      all heim_any and OCTET STRING content (better than its current
      --inner option)
2019-10-08 22:20:40 -05:00
Nicolas Williams
6a7e7eace6 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
2019-10-08 21:26:50 -05:00
Nicolas Williams
78cb995e6e krb5: add missing export 2019-10-08 20:58:04 -05:00
Nicolas Williams
d31dd9e00b hx509: make file store writes atomic
Now we'll use mkostemp() and rename() into place to make
hx509_certs_store() atomic for FILE/DER-FILE/PEM-FILE stores.

This is not ideal, as it can leave temp files in place if a process
crashes in between the mkostemp() and the rename into place.

On Linux we'll eventually make use of O_TMPFILE and linkat().  The idea
will be to first create an anonymous, zero-link file in the directory
that will contain the file at the end, write the file, then linkat() the
file into place as a .new file, then rename() the .new into place.  That
will limit the amount of junk that may be left behind to just one file.
(If the linkat() fails, then unlink() the .new and try again.  If the
rename() fails that just means the caller raced with another and the
operation is complete.)

We should really make a lib/roken interface that does this.
2019-10-08 20:58:04 -05:00