Skip to content

Commit 3703b26

Browse files
committed
fix(pki): resolve TPM signing CA from repo root
1 parent 6b3248a commit 3703b26

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

overlays/tpm_tls_sign.nix

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ in {
99
runtimeInputs = [
1010
clan-core.packages.${system}.clan-cli
1111
final.coreutils
12+
final.gitMinimal
1213
final.openssl
1314
];
1415
text = ''
@@ -27,6 +28,13 @@ in {
2728
key="$work/ca.key"
2829
serial="$work/ca.srl"
2930
31+
repo="''${CLAN_DIR:-$(git rev-parse --show-toplevel)}"
32+
root_crt="$repo/vars/shared/tls-ca/ca.crt/value"
33+
if [[ ! -s "$root_crt" ]]; then
34+
echo "missing root CA certificate: $root_crt" >&2
35+
exit 1
36+
fi
37+
3038
cleanup() {
3139
rm -f "$root_key"
3240
}
@@ -43,7 +51,7 @@ in {
4351
openssl x509 \
4452
-req \
4553
-in "$csr" \
46-
-CA vars/shared/tls-ca/ca.crt/value \
54+
-CA "$root_crt" \
4755
-CAkey "$root_key" \
4856
-CAserial "$serial" \
4957
-CAcreateserial \
@@ -52,7 +60,7 @@ in {
5260
-sha256 \
5361
-extfile ${intermediateCaExt}
5462
55-
openssl verify -CAfile vars/shared/tls-ca/ca.crt/value "$crt"
63+
openssl verify -CAfile "$root_crt" "$crt"
5664
5765
clan vars set "$machine" tpm/ca.key < "$key"
5866
clan vars set "$machine" tpm/ca.crt < "$crt"

0 commit comments

Comments
 (0)