Files
KNELCa/selftest.sh
mrcharles 55f59e9a7e
ci / audit (push) Successful in 44s
[#784] CI gate alignment: prune legacy/agent dirs from shellcheck; fix SC2015/SC2002
Debian shellcheck (CI job container) vs koalaman:stable skew resolved by
fixing real findings + exempting ported legacy suites and non-shell agent
scripts, mirroring the archive/ treatment.
https://projects.knownelement.com/issues/784
2026-09-05 06:21:17 -05:00

18 lines
841 B
Bash

#!/bin/bash
#
# selftest.sh — throwaway end-to-end CA loop in /tmp [#697]
# TDD gate for the CA tooling: init -> issue -> verify chain -> negative check.
#
set -euo pipefail
T="$(mktemp -d)"
trap 'rm -rf "$T"' EXIT
bash "$(dirname "$0")/ca-init.sh" "$T/root" "$T/int" > /dev/null
if [ ! -s "$T/root/root.key" ] || [ ! -s "$T/int/intermediate.crt" ]; then echo "FAIL: init"; exit 1; fi
INT_DIR="$T/int" bash "$(dirname "$0")/issue-cert.sh" test.knel.net "DNS:test.knel.net,IP:10.0.0.1" > /dev/null
openssl verify -CAfile "$T/root/root.crt" "$T/int/intermediate.crt" > /dev/null
openssl x509 -in "$T/int/certs/test.knel.net.crt" -noout -ext subjectAltName | grep -q "test.knel.net"
openssl x509 -in "$T/int/certs/test.knel.net.fullchain" -noout | head -1 > /dev/null
echo "SELFTEST PASS: root->intermediate->leaf chain verified with SANs"