Commit Graph

28934 Commits

Author SHA1 Message Date
Nicolas Williams
5e270a8914 Fix missing error checking in lib/krb5/pkinit.c 2019-10-03 13:09:18 -05:00
Nicolas Williams
44677c01ae hxtool print: fix output device bugs 2019-10-03 13:09:18 -05:00
Nicolas Williams
63ccdca137 hx509: _hx509_certs_keys_free() should not require gate 2019-10-03 13:09:18 -05:00
Nicolas Williams
d13f89cb11 hx509: expose hx509_request_parse*() 2019-10-03 13:09:18 -05:00
Nicolas Williams
87eb05df6a hx509: always verify CSR signature 2019-10-03 13:09:18 -05:00
Nicolas Williams
f2776ce841 hx509: make hx509_get_error_string(NULL, ...) work
If hx509_context_init() fails we should still be able to do something
with its return code.
2019-10-03 13:09:18 -05:00
Nicolas Williams
eaebb892b8 hx509: hx509_context_free(&null_var) should work 2019-10-03 13:09:18 -05:00
Nicolas Williams
41fcafd20c hx509: add hx509_certs_destroy() 2019-10-03 13:09:18 -05:00
Nicolas Williams
e4b35ba13f hx509: create files with safe mode_t 2019-10-03 13:09:18 -05:00
Nicolas Williams
5a0d85e423 hx509: Add PKCS#8 private key format option 2019-10-03 13:09:18 -05:00
Nicolas Williams
63116100a8 hx509: do not crash on missing FILE: name 2019-10-03 13:09:18 -05:00
Nicolas Williams
cc8a5c59a8 hxtool: add generate-key command
This will help us not commit private keys in-tree for testing as we can now
more easily generate them as needed.
2019-10-03 13:09:18 -05:00
Nicolas Williams
049d817c66 Fix hx509_ca_tbs_free() segfault 2019-10-03 13:09:18 -05:00
Nicolas Williams
a2db5caebf Add note about racy tests 2019-10-03 13:09:18 -05:00
Nicolas Williams
859c587dc2 Add more hxtool EKU options, and KeyUsage too
This is necessary in order to have more control over, e.g., template
certificates for kx509.  But also it's good to have this more generally.

Some batteries not included.  Specifically: no attempt is made to validate that
given KeyUsage values are compatible with the subjectPublicKey's alrogithm and
parameters.
2019-10-03 13:09:18 -05:00
Nicolas Williams
005ba36b83 hxtool request-create: fix --key argument handling
```
    hxtool request-create --subject=... \
                          --generate-key=... \
                          --key-bits=... \
                          --key=STORE \
                          store
```

wants to generate a key, store it in the location specified by the --key
argument, then read it back, then generate the CSR, and store it in
`store`.

But it didn't work because for generating a key this really wants the
`--key` argument to be a file path into which a raw DER-encoded RSA key
will be written (only RSA is supported, ay!), but for reading the key
back it uses `hx509_certs_init()`, which wants `TYPE:name` keystore
specification.  A deadly embrace.

Now that we have improved libhx509 functionality for reading/writing
private keys from/to PEM files we use this functionality and require a
store type in the `--key=STORE` argument.
2019-10-03 13:09:18 -05:00
Nicolas Williams
252487dfe4 hx509: support reading private keys from PEM files
This commit adds:

 - hx509_cert_init_private_key() for creating an hx509_cert object that
   has just a private key

 - hx509_cert_have_private_key_only() for checking whether an hx509_cert
   object has just a private key

This also generalizes the get_key() internal function in hxtool, which
is tasked with reding or generating a private key for use in signing
CSRs.  Now hxtool request-create can read/write private keys to/from PEM
files, not just DER files.

This is needed to support key types other than just RSA for CSRs and
certificates.
2019-10-03 13:09:18 -05:00
Nicolas Williams
8d232aa87d hx509: export hx509_parse_private_key (Windows) 2019-10-03 13:09:18 -05:00
Nicolas Williams
1ee136ce40 autoconf: look for unlinkat() 2019-10-03 13:09:18 -05:00
Nicolas Williams
34728ce79e rk_base64_encode(): set errno in all error cases 2019-10-03 13:09:18 -05:00
Nicolas Williams
1ae941af9b roken_detach_prep() should return fd 2019-10-03 13:09:18 -05:00
Nicolas Williams
5859bc3bdf kadmin: add --hdb / -H argument
Makes it possible to

 $ kadmin -l -H /tmp/hdb init FOO.EXAMPLE

rather than being able to only init /var/heimdal/heimdal.
2019-10-03 13:09:18 -05:00
Nicolas Williams
338d47120b Fix Appveyor Windows build 2019-10-03 13:09:18 -05:00
Viktor Dukhovni
989422e0fc Install kuserok-plugin.h and update docs
The header file was not installed, and the manpage had the wrong
name for the plugin load function, it is "krb5_plugin_kuserok_plugin_load",
not "kuserok_plugin_load".
2019-09-26 20:18:00 -04:00
Nicolas Williams
c9b5a4df90 Use roken_get_loginname() when we want getlogin_r() 2019-09-25 23:09:20 -05:00
Nicolas Williams
d02277b45f List token expansions in krb5.conf.5 2019-09-25 23:09:20 -05:00
Nicolas Williams
0fdda02b61 Add loginname, ruid, and LOCALSTATEDIR expansions
%{loginname} is for getlogin_r().

Now %{username} uses only the $USER and $LOGNAME environment variables
(if the caller is not set-uid), or if absent or the caller is set-uid,
then getpwuid_r().

The intent is to allow kadmin(1) to use the loginname instead of the
username for the construction of the kadmin client principal name.  This
is helpful when the user runs kadmin as root via sudo and/or su.
2019-09-25 23:09:20 -05:00
Nicolas Williams
141289f14b roken: add roken_get_loginname() 2019-09-25 23:09:20 -05:00
Roland C. Dowdeswell
366b787917 We provide a "derived key" mechanism to allow wildcard princs
In order to support certain use cases, we implement a mechanism to
allow wildcard principals to be defined and for the KDC to issue
tickets for said principals by deriving a key for them from a
cluster master entry in the HDB.

The way that this works is we defined an entry of the form:

	WELLKNOWN/DERIVED-KEY/KRB5-CRYPTO-PRFPLUS/<hostname>@REALM

When reading from the Kerberos DB, if we can't find an entry for
what looks like a hostbased principal, then we will attempt to
search for a principal of the above form chopping name components
off the front as we search.

If we find an entry, then we derive keys for it by using
krb5_crypto_prfplus() with the entry's key and the principal name
of the request.
2019-09-18 21:20:47 +01:00
Roland C. Dowdeswell
d6337ebdce Export krb5_crypto_prfplus() from libkrb5 2019-09-18 21:20:47 +01:00
Viktor Dukhovni
20557e2255 Don't send diffs to slaves with not yet know version 2019-09-16 17:28:49 -05:00
Viktor Dukhovni
7680c92047 Don't stutter in send_diffs
When the master sees a burst of updates (perhaps sustained), the
slaves "I_HAVE" messages can fall behind the version we've already
sent, and the unpatched code would retransmit already sent diffs!

This can result in substantial amplification (in a local test, 3000
ops turned into 427,000 ops).  Though the number of *messages* sent
was actually somewhat smaller, the ever growing message size
ultimately leads to failure.
2019-09-14 23:40:46 -05:00
Nicolas Williams
2709f28a1b Make gss_store_cred*() work
krb5_cc_cache_match() searches all ccache collections for a ccache that
has credentials for a given principal name.  This includes MEMORY
ccaches, which means it can find the same ccache as is referenced by a
GSS cred handle given to gss_store_cred(), which means that
gss_store_cred() can fail.

For now we work around this by including a private variant of
krb5_cc_cache_match() that only searches the default ccache, not all
collections.  Eventually we should ensure that krb5_cc_default() also
searches all collection-type (other than MEMORY) ccaches for a default
credential, then we can go back to using krb5_cc_cache_match() (though
we'll need to make sure that MEMORY is searched last or not at all).
2019-09-05 09:52:49 -05:00
Viktor Dukhovni
fae8df3839 Optional backwards-compatible anon-pkinit behaviour
* Anonymous pkinit responses from the KDC where the name
  type is not well-known (as issued by 7.5 KDCs and earlier)
  are accepted by the client.  There is no need for the client
  to strictly enforce the name type.

* With historical_anon_pkinit = true, the kinit(1) client's
  "--anonymous" option only performs anon pkinit, and does
  not require an '@' prefix for the realm argument.

* With historical_anon_realm = true, the KDC issues anon
  pkinit tickets with the legacy pre-7.0 "real" realm.
2019-09-04 18:00:15 -04:00
Nicolas Williams
f40d393c83 tests/kdc/check-authz still fails
I couldn't figure out why this fails in Travis, so I'm nuking it.
2019-07-09 15:47:12 -05:00
Nicolas Williams
4edcbd6597 Fix Travis after_failure 2019-07-09 15:47:12 -05:00
Nicolas Williams
9c51900238 Declare kdc log functions to be printf-like
And add a kdc_vlog() function.
2019-07-09 13:17:06 -05:00
Nicolas Williams
7fc90ce1c8 Remove references to Kerberos v4 from kdc/kdc.8 2019-07-09 12:38:08 -05:00
Nicolas Williams
32bc4083c4 libhx509: export some missing symbols 2019-07-09 12:34:26 -05:00
Nicolas Williams
dd226b6f9a Token "username" should be multi-platform 2019-07-09 12:34:26 -05:00
Nicolas Williams
8bc5d5af10 hcrypto: fix off-by-one set-bit counting 2019-07-09 12:34:26 -05:00
Nicolas Williams
51aed5d820 krb5_data_copy() should use memcpy() 2019-07-09 12:34:26 -05:00
Nicolas Williams
889617883d Make note in test_cc of how to keyctl new_session 2019-07-09 12:34:26 -05:00
Nicolas Williams
1af64c5de5 Do not use real $HOME in tests/kdc/check-authz
This test would fail if ~/.k5login has incorrect permissions.

Now we set $HOME to $objdir and use a canned .k5login.
2019-07-09 12:27:16 -05:00
Roland C. Dowdeswell
f2bd714e69 Fix build for out-of-source objdir 2019-06-21 11:32:03 -04:00
Roland C. Dowdeswell
9aa573c9ce kdc: no error if req is fwdable on non-fwdable princ
Instead of returning an error if the client asks for
a forwardable ticket where it isn't allowed, we simply
return one that isn't forwardable.
2019-06-21 10:11:58 -04:00
Roland C. Dowdeswell
fcd57af8e1 Implement KRB5_TRACE using existing logging framework 2019-06-16 21:23:51 -04:00
Jeffrey Altman
15ae5f06a9 Update SECURITY.md
This is a new PGP key for heimdal-security@heimdal.team
2019-06-09 13:43:47 -04:00
Jeffrey Altman
4a4971a496 Create SECURITY.md 2019-06-09 13:43:47 -04:00
Jeffrey Altman
7d8a72dbe6 .gitignore
RimStar state file (rs_state.ini)

Change-Id: I110de7d64e23d644d70f8b37f4f5d7c2e3d087a4
2019-06-07 22:12:54 -04:00