tpm-enrol: inline empty-NV first-boot enrolment (host side, TODO #11)
Builds the host side of TPM identity enrolment — the "inline single-UKI"
vehicle from docs/tpm-enrolment-design.md. A production (secure) UKI now
auto-enrols a fresh host with no client cert, then reboots into the normal
secure path.
New dracut hook files/dracut/95dot1x-macsec/tpm-enrol.sh (initqueue/settled
prio 25, BEFORE dot1x-macsec-up at 30):
- no-op when a cert is already present in NV 0x01800001 (normal boot) or
under rd.dot1x=0 (test path has no trustworthy identity to enrol);
- on EMPTY NV: generate the signing key in the TPM @0x81010001 (openssl tpm2
provider builds the CSR; key never leaves the TPM), pre-auth DHCP on the
PHYSICAL NIC (nmcli re-manages en*, overriding the secure-mode unmanaged
drop-in), POST CSR+context to rd.fleet.enrol_url, show the broker
fingerprint on Plymouth, poll /status, write the issued leaf cert (DER) to
NV, and reboot to converge.
- Empty-NV and the secure path are mutually exclusive, so this never reorders
the load-bearing boot sequence (invariant #2).
Wiring:
- module-setup.sh: require+install the tpm2 key-gen/NV tools, curl, awk, and
the openssl tpm2 PROVIDER (ossl-modules/tpm2.so, asserted present — tpm2-tss
alone can't sign with a handle: key); install the hook.
- diskless.pkr.hcl: install tpm2-openssl + curl; assert hook/tools/provider in
the initramfs (invariant #9). New enrol_url var threaded to extract-artifacts.
- extract-artifacts.sh: bake rd.fleet.enrol_url into the cmdline.
- fleet.script: enrol-active/enrol-wait/enrol-done banner; fingerprint on the
message line (public — states only, invariant #1).
Shell JSON build/parse/cert-extract pipeline (no jq in the initramfs) verified
end-to-end against a live broker. BENCH-VERIFY list in docs/TODO.md #11 (tpm2
provider key-ref on real/swtpm, empty-NV detect, pre-auth DHCP override, Plymouth
render, NV write + reboot convergence, prod HTTPS).
This commit is contained in:
@@ -7,6 +7,12 @@
|
||||
|
||||
check() {
|
||||
require_binaries wpa_supplicant wpa_cli tpm2_nvread openssl || return 1
|
||||
# Inline empty-NV enrolment (tpm-enrol.sh) needs the TPM key-gen + NV-write
|
||||
# tools, curl (broker HTTP), and awk (JSON build). require them so a build
|
||||
# that lacks tpm2-openssl / curl fails LOUDLY here rather than shipping a UKI
|
||||
# that silently cannot enrol a fresh host.
|
||||
require_binaries tpm2_createprimary tpm2_create tpm2_load tpm2_evictcontrol \
|
||||
tpm2_nvdefine tpm2_nvwrite tpm2_readpublic curl awk || return 1
|
||||
return 0
|
||||
}
|
||||
|
||||
@@ -37,8 +43,23 @@ install() {
|
||||
inst_multiple wpa_supplicant wpa_cli tpm2_nvread openssl ip setsid nmcli \
|
||||
grep sed cut tr sha256sum sleep mkdir nvme
|
||||
|
||||
# TSS libraries that tpm2_nvread dlopens
|
||||
# Inline empty-NV enrolment (tpm-enrol.sh): TPM key-gen + NV-write tools, the
|
||||
# EK read (device context), curl (broker HTTP), awk (JSON), wc, and reboot.
|
||||
inst_multiple tpm2_createprimary tpm2_create tpm2_load tpm2_evictcontrol \
|
||||
tpm2_nvdefine tpm2_nvundefine tpm2_nvwrite tpm2_readpublic \
|
||||
tpm2_createek tpm2_flushcontext curl awk wc reboot systemctl
|
||||
|
||||
# TSS libraries that the tpm2 tools + the openssl tpm2 provider dlopen.
|
||||
inst_libdir_file "libtss2-*"
|
||||
# openssl tpm2 PROVIDER (tpm2-openssl): openssl req signs the CSR with the
|
||||
# TPM key via `-provider tpm2 -key handle:0x…`. tpm2-tss alone is NOT enough
|
||||
# — the provider .so is what exposes the handle: key ref. require_binaries
|
||||
# can't see a provider, so assert the .so landed (else enrolment CSR fails).
|
||||
inst_libdir_file "ossl-modules/tpm2.so"
|
||||
if [ -z "$(find "${initdir}" -name 'tpm2.so' -path '*ossl-modules*' 2>/dev/null)" ]; then
|
||||
derror "95dot1x-macsec: openssl tpm2 provider (ossl-modules/tpm2.so) missing — install tpm2-openssl"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Fleet-generic supplicant config + RADIUS CA
|
||||
inst_simple /etc/dot1x/wpa_supplicant-dot1x.conf /etc/dot1x/wpa_supplicant-dot1x.conf
|
||||
@@ -51,6 +72,11 @@ install() {
|
||||
# 99-dot1x-unmanaged.conf, which couldn't be mode-aware.
|
||||
inst_hook cmdline 10 "$moddir/nm-unmanaged.sh"
|
||||
|
||||
# Inline empty-NV enrolment: runs BEFORE dot1x-macsec-up.sh (priority 25 < 30).
|
||||
# No-op when a cert is already present (normal boot) or under rd.dot1x=0; on a
|
||||
# fresh host it enrols an identity into NV then reboots into the secure path.
|
||||
inst_hook initqueue/settled 25 "$moddir/tpm-enrol.sh"
|
||||
|
||||
# Hook: runs from the initqueue once the NIC exists, before netroot
|
||||
inst_hook initqueue/settled 30 "$moddir/dot1x-macsec-up.sh"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user