2
0
mirror of https://github.com/xcat2/confluent.git synced 2026-09-04 20:17:58 +00:00
Commit Graph

43 Commits

Author SHA1 Message Date
Markus Hilger 4b61351373 Create and maintain the TLS CA as the confluent service account
The CA database under /etc/confluent/tls/ca is typically created by a root context such as osdeploy initialize -t, but the confluent service runs as the owner of /etc/confluent, and openssl ca rewrites the database (index, serial) as the invoking user on every issuance. Certificate issuance through the running service (e.g. the /self/tlscert deployment API) then fails on the root-owned database until packaging happens to repair the ownership.

Run the CA creation (full CA and the currently unused simple CA variant) and the openssl ca invocation under normalize_uid, the convention already used when publishing the CA certificate. The issued certificate is staged through a temporary file since the destination may only be writable by the invoking user, e.g. the web server certificate paths.

Existing root-owned CA databases are repaired by packaging or manually via: chown -R --reference=/etc/confluent /etc/confluent/tls
2026-07-15 05:55:48 +02:00
Markus Hilger 2af402b13c ruff auto fixes
Apply ruff's safe autofixes.
The changes are mechanical and behaviour-preserving. Issues fixed:

- F401: remove unused imports.
- F841: drop unused local variables and assignments, including discarded
  await/return values, unused "except ... as e" bindings, and unused
  "with ... as name" targets.
- F541: remove the f prefix from f-strings that contain no placeholders.
- E711: compare against None with "is"/"is not" instead of "=="/"!=".
- E712: test truthiness directly instead of comparing to True.
- E713: use "x not in y" instead of "not x in y".
- E714: use "is not" instead of "not ... is".
- E731: convert lambdas bound to a name into def statements.
- W291/W293: trim trailing whitespace on touched lines.
2026-07-14 05:03:58 +02:00
Jarrod Johnson 3ce0988f5a Fix -s on certutil 2026-06-29 11:30:49 -04:00
Jarrod Johnson 2c669358b3 Restore ability for certutil to run as standalone script
Also make days an argument
2026-06-26 12:12:25 -04:00
Jarrod Johnson a5e7fe93e4 Fix ip address list 2026-03-03 17:12:28 -05:00
Jarrod Johnson bfb41de43b Further asyncio conversion work 2026-03-03 16:06:14 -05:00
Jarrod Johnson 2f2afd970a Merge branch 'master' into async 2026-02-25 10:02:05 -05:00
Jarrod Johnson 74dda48513 Provide helper script for setting up nokia switches 2026-02-23 10:15:55 -05:00
Jarrod Johnson d89305ca42 Merge branch 'master' into async
Try to merge in 2025 work into async
2026-01-20 14:24:01 -05:00
Jarrod Johnson b07da455c2 Fix SAN generation
The nameconstraint support missed
a branch, fix this.
2025-11-07 11:22:12 -05:00
Jarrod Johnson 2826abb7ab Prune excessive leftover ext config files 2025-11-03 14:21:36 -05:00
Jarrod Johnson 5de063212f Prepare for supporting constrained CA
If asked to sign using a name constrained CA,
avoid generating a certificate that
would violate those constraints.
2025-11-03 10:43:34 -05:00
Jarrod Johnson f755ba9f91 Implement method to sign BMC certificates 2025-10-31 10:46:42 -04:00
Jarrod Johnson f0a779764d Fix ordering of digest argument
The digest argument was erroneously inserted between startdate and it's
argument, correct this mistake.
2025-10-28 15:39:04 -04:00
Jarrod Johnson 24a76612ae Use sha284 hash algorithm
Some implementations reject sha256 as inadequate if ecdsa has 384 bit keylength. Bring the digest up to match
the key size for the ECDSA.
2025-10-27 06:41:05 -04:00
Jarrod Johnson 6c9c58f464 Update certutil to prepare for broader usage
For one, apply more rules from CA/B forum. This includes including KU and EKU extensions, marking basicConstraints critical, and
randomized serial numbers.

Also make the backdate and end date configurable, to allow
for the BMC certs to have a more palatable validity interval.
2025-10-26 14:57:26 -04:00
Jarrod Johnson 3125f4171b Begin overhaul of TLS cert management
Begin expanding certutil to sign other certificates from external CSRs more easily.

Have certutil make the CA constraint critical.

Have the fingerprint based validator have a mechanism to check for properly signed certificate in lieu of exact match,
and update the stored fingerprint
on match.

Provide a means to request a custom subject when evaluating a
target.

Change redfish plugin to set that subject in the verifier.
2025-10-24 20:02:51 -04:00
Jarrod Johnson a71804a13b Fix suse/ubuntu paths for apache config 2025-08-12 11:47:39 -04:00
Jarrod Johnson 902ff43a9b Extend certificate management
Provide checks for nginx config and apache configuration, perhaps even concurrently.

Latch on the first match, since we are taking care of IP based SANs and subsequent server/virtualhost sections are irrelevant.

Latch onto a chain file, if indicated in the apache configuration, placing our CA in the chain.

For nginx, put our CA in the cert, since nginx
uses the 'certificate' file as the chain.

In this scenario, a cross-signed CA cert is possible.
2025-08-08 17:27:26 -04:00
Jarrod Johnson d66df7ee4b Merge branch 'master' into async
Need to rework httpapi further for changes to the firmware staging.
2025-01-08 14:23:52 -05:00
Jarrod Johnson 71a83ac39c Try for more DNS lookups
Try to hit likely DNS names, or at least provide a means
of manipulating /etc/hosts to induce
a good domain for the default certificate SAN fields.

Note putting the FQDN first in /etc/hosts will get the FQDN in the
certificate.
2024-09-20 18:34:02 -04:00
Jarrod Johnson c754dc2641 Merge branch 'master' into async 2024-08-08 09:45:15 -04:00
Jarrod Johnson 30aa6f382c Ignore duplicate specifications of same key
Particularly if traversing a lot of linked configuration, the same key/cert
path may come up multiple times, check for equality
and if equal, just keep going.
2024-07-25 14:54:15 -04:00
Jarrod Johnson bdb7f064d6 Rework a number of subprecess calls and osdeploy
Some subprocess calls were reworked to use asyncio friendly
variants.

Also, osdeploy initialize was checked, and reworked the ssh and tls
handling.

osdeploy import was also reworked to functional with async only.
2024-05-31 17:22:26 -04:00
Jarrod Johnson 34804b2d5f Provide components for cert management with modern XCC
Refresh getcsr and installcert to handle latest firmware.

Also add ability to have pre-existing CSR, and trust the SAN on the way through.

If this becomes more properly a feature, then would likely impose a SAN
on certs, similar to the SSH principals, rather than deferring to the CSR
to get it right.
2024-04-01 12:13:21 -04:00
Jarrod Johnson f475d58955 Various permission fixes for osdeploy initialize
Fix a few scenarios where certain ordering of
initialize creates unworkable permissions.
2023-11-13 15:43:11 -05:00
Jarrod Johnson 5ee6d0ca5d Fix ordering of arguments
The -text was between startdate and its argument
2022-06-09 08:30:03 -04:00
Jarrod Johnson 2825af19c4 Do not clutter the pem file with text 2022-06-09 08:04:15 -04:00
Jarrod Johnson 5ee0572f54 Change to using 'full' openssl ca
OpenSSL does not allow access to custom start
date without the full 'ca' facility, do the
work to set up the full CA and then
backdate certificates.

This does open the way for managed CA if required.
2022-06-08 17:10:11 -04:00
Jarrod Johnson f10a27fd7a Switch to mkstemp
Use mkstemp to more confidently reserve a filename as expected.
2022-02-15 17:13:04 -05:00
Jarrod Johnson 2d13921d54 Amend deployment initialize for consistent ownership
Depending on the options selected/not selected, the
/var/lib/confluent directory may have been initialized
incorrectly.  Have all the potential paths begin with
ensuring /var/lib/confluent is correct, and then
use seteuid consistently to take care of the rest.
2022-01-14 15:08:19 -05:00
Jarrod Johnson 773be640f8 Fix for long hostname on CA node 2021-12-09 11:19:16 -05:00
Jarrod Johnson 343e5eabe5 Utility function for running commands
Given the python2/3 differences, good to have a single run
that returns stdout and stderr.

This should trigger the same behavior as timeout did, but
in a manner consistent between 2 and 3.
2021-12-08 10:20:34 -05:00
Jarrod Johnson 0092915cab Fix rerunning tls initialization 2021-12-02 10:19:47 -05:00
Jarrod Johnson 40dea6a747 Support older python subprocess
Older python did not provide timeout.  Keep the timeout
for the modern python that skips select without a timeout,
but try again without timeout to retain compatibility.
2021-10-20 18:23:35 -04:00
Jarrod Johnson 929392c746 Fix hangs on check_output
Eventlet narrowly targets overriding
select in subprocess, to avoid rewriting adequate functions.

However, subprocess does an 'optimization' to skip
select if there's fewer than 3 pipes to juggle and no timeout specified.

Induce python to always use select
by specifying a very long timeout.

This causes confluent to be able to spawn multiple subprocesses and
not be hung waiting for input.
2021-09-23 10:42:47 -04:00
Jarrod Johnson 4ab5cac3eb Generate random serial number for certificate
Hardcoding 0x123 serial number would cause strict clients to reject the
certificate.

While we are still not guaranteeing uniqueness, the chances of a
duplicate are impossibly small.
2021-09-22 07:48:44 -04:00
Jarrod Johnson ef1649208e Switch to using separate CA for TLS
This allows regenerating TLS cert
without updating boot images.

For example, if ip address changes need a new cert, no
longer should the nodes need new certs to trust
just due to that.
2021-06-30 14:25:46 -04:00
Jarrod Johnson 85c4ec5654 Skip fqdn in cert generation
There are scenarios where getqfdn can induce a hang.
The certificate having FQDN isn't that useful anyway,
since confluent never uses it and external use of it
may need more carefully crafted certificate to have
a good chance of matching it anyway.

Also, the chances a user would import our cert as a
CA to something like a browser are low.
2021-03-29 14:29:42 -04:00
Jarrod Johnson 5f170585c5 Adjust SUSE logic to work
Finding the apache configured
TLS cert location now works in
an easy configuration.
2020-05-28 16:47:36 -04:00
Jarrod Johnson ba0d600bf7 Prepare osimage initialize
Provide a helper for the various
setup steps required for
getting ready for OS deployment.
2020-05-21 17:07:58 -04:00
Jarrod Johnson eda645b792 Freshen up ssh and tls helpers
TLS will now work from scratch

SSH user key management updated to final design
2020-05-21 16:26:01 -04:00
Jarrod Johnson 8ce8f18f56 Change certutil to be a module
This allows it to be used from within
osimage command.
2020-05-21 15:56:16 -04:00