95 Commits

Author SHA1 Message Date
Nicolas Williams
be0d1e68e5 hx509: Add support for CSRs w/ BasicConstraints 2023-11-08 14:22:02 -06:00
Nicolas Williams
d24b7fd8b2 hx509: Add hxtool cc --no-root-certs, --no-private-keys, and --append options 2022-12-19 16:26:03 -06:00
Nicolas Williams
15b2094079 hx509: Add Heimdal cert ext for ticket max_life
This adds support for using a Heimdal-specific PKIX extension to derive
a maximum Kerberos ticket lifetime from a client's PKINIT certificate:

 - a `--pkinit-max-life` to the `hxtool ca` command
 - `hx509_ca_tbs_set_pkinit_max_life()`
 - `hx509_cert_get_pkinit_max_life()`
 - `HX509_CA_TEMPLATE_PKINIT_MAX_LIFE`

There are two extensions.  One is an EKU, which if present means that
the maximum ticket lifetime should be derived from the notAfter minus
notBefore.  The other is a certificate extension whose value is a
maximum ticket lifetime in seconds.  The latter is preferred.
2021-03-24 19:12:00 -05:00
Nicolas Williams
bb3499aa53 hxtool: Add print --raw-json option
Add a `--raw-json` to `hxtool print` that uses the new ASN.1 value
printer functionality from libasn1.
2021-02-28 18:15:57 -06:00
Nicolas Williams
37ab2a5308 hx509: Add DNSSRV and TCG SAN types and DN attrs
This adds hx509 API and hxtool(1) support for PermanentIdentifier,
HardwareModuleName, and DNSSRV SAN types, as well as for serialNumber,
TPMManufacturer, TPMModel, and TPMVersion DN attributes.
2021-01-15 13:21:18 -06:00
Nicolas Williams
dbb0463ca8 hx509: Add support for cert policies and mappings 2021-01-15 13:21:18 -06:00
Nicolas Williams
e515745996 hx509: private key exclusion options
Add two ways to exclude private keys when dealing with an hx509
certificate store.  One as a load option (load no private keys, never
add private keys), one as a store option (store no private keys).

This is useful for CA code so it can have a single store with the
issuer's credentials _and_ the chain for it, and copy those to a store
with the issued certificate and _not_ accidentally include the issuer's
private key.

It would be much safer still to flip the default for this flag, but that
could break out-of-tree libhx509 dependents.
2019-12-09 18:10:10 -06: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
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
93e48f8fba hxtool: Add OID symbol resolution 2019-10-07 21:32:00 -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
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
Jelmer Vernooij
70e43e9808 Fix some typos. 2014-04-25 02:42:17 +02:00
Love Hörnquist Åstrand
c69c4634ad allow setting signature algorithm 2014-02-12 09:46:02 -08:00
Love Hornquist Astrand
bcbd477a20 support parsing PEM CRL files and printing revoke contexts 2013-04-27 12:42:12 -07:00
Roland C. Dowdeswell
67d9094665 Allow hxtool to process multiple --pk-init-principal args. 2012-04-05 20:20:19 +01:00
Love Hornquist Astrand
b11217838e --no-embedded-certs and --embed-leaf-only 2010-08-10 10:20:13 -07:00
Love Hornquist Astrand
92075b8825 add allow wrong oid flag, short for trust anchors 2009-09-23 00:02:46 -07:00
Love Hornquist Astrand
30aa8a7166 there is already one verify, don't make two 2009-08-21 13:42:22 -07:00
Love Hornquist Astrand
03cb3aa56b use EVP_MD_CTX_create 2009-08-20 17:13:09 -07:00
Love Hornquist Astrand
e3da85a4ab add aliases to commands 2009-08-20 14:05:18 -07:00
Love Hornquist Astrand
f0aec0e637 allow one argument 2009-08-20 10:20:09 -07:00
Love Hörnquist Åstrand
d17fab3f7b add --never-fail flag to print
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@25222 ec53bebd-3082-4978-b11e-865c3cabbd6b
2009-05-25 23:43:36 +00:00
Love Hörnquist Åstrand
7c796daa23 add allow weak crypto flag
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@24959 ec53bebd-3082-4978-b11e-865c3cabbd6b
2009-03-26 23:12:24 +00:00
Love Hörnquist Åstrand
74ed9683a6 handle unsigned SignedData in cms-create-sd and cms-verify-sd
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@24587 ec53bebd-3082-4978-b11e-865c3cabbd6b
2009-02-04 22:05:41 +00:00
Love Hörnquist Åstrand
e172367898 switch to utf8 encoding of all files
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@23814 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-09-13 08:53:55 +00:00
Love Hörnquist Åstrand
8327309499 make it clear that ca --type can be used more then once.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@23344 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-07-14 13:43:03 +00:00
Love Hörnquist Åstrand
7776ed30a9 Add language to support querying certificates to find a match. Support constructs like "1.3.6.1.5.2.3.5" IN %{certificate.eku} AND %{certificate.subject} TAILMATCH "C=SE"".
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@22677 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-03-13 17:35:49 +00:00
Love Hörnquist Åstrand
8348b37a6b Add --pem to cms-verify-sd.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@22653 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-02-26 12:29:39 +00:00
Love Hörnquist Åstrand
0ff6dbc8bb Add matching on EKU, validate EKUs, add hxtool matching glue, add check. Adapted from pach from Tim Miller of Mitre
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@22538 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-01-27 13:05:47 +00:00
Love Hörnquist Åstrand
c2164a1781 Adapt to new request handling.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@21343 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-06-26 14:21:55 +00:00
Love Hörnquist Åstrand
ddc4a41685 (cms-create-signed): add --pem
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@21302 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-06-25 16:44:55 +00:00
Love Hörnquist Åstrand
c5e18ae5eb add --hostname add --max-depth
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@21276 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-06-25 04:50:40 +00:00
Love Hörnquist Åstrand
a3fec27a13 add cms-create-sd --id-by-name
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@21269 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-06-24 19:25:28 +00:00
Love Hörnquist Åstrand
c9d85b6204 Add content-type.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@21167 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-06-19 00:11:03 +00:00
Love Hörnquist Åstrand
9d1bb9e015 Add cms-create-sd --peer-alg.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@20935 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-06-06 20:21:54 +00:00
Love Hörnquist Åstrand
baee263bda Default path-length to -1.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@20905 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-06-05 01:59:19 +00:00
Love Hörnquist Åstrand
9ccb8e8d8b Add lifetime to crls.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@20851 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-06-03 18:00:59 +00:00
Love Hörnquist Åstrand
1e223ee1a9 argument is certificates.. for crl-sign
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@20847 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-06-03 15:30:36 +00:00
Love Hörnquist Åstrand
ac5c46095d New command ocsp-verify.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@20805 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-06-03 03:08:39 +00:00
Love Hörnquist Åstrand
5f546a763e Add crl-sign commands.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@20797 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-06-02 03:28:26 +00:00
Love Hörnquist Åstrand
d2d30f8b2a Add statistics hook.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@20773 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-06-01 21:58:56 +00:00
Love Hörnquist Åstrand
27cd38c109 make ca and alias of certificate-sign
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@20725 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-05-31 13:14:55 +00:00
Love Hörnquist Åstrand
499cb7937a Add ca --ms-upn.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@20722 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-05-31 02:45:11 +00:00
Love Hörnquist Åstrand
9081ac940b add ca --domain-controller
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@20711 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-05-30 22:58:21 +00:00
Love Hörnquist Åstrand
64ff82a9eb add test-crypto command
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@20666 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-05-10 23:18:58 +00:00
Love Hörnquist Åstrand
56b26bb2cc Add options to generate detached signatures.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@20169 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-02-03 22:45:55 +00:00
Love Hörnquist Åstrand
f2b0cd7d5a add ca --crl-uri
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@20104 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-01-31 15:54:40 +00:00
Love Hörnquist Åstrand
884b0179aa Add certificate template processing.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@19895 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-01-14 18:15:53 +00:00
Love Hörnquist Åstrand
1739d7acbe (certificate-sign): add --jid
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@19862 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-01-12 08:44:58 +00:00