Закрыть оценку 4 и трек 1: отзыв leaf и права worker.
Skeleton contracts / contracts (pull_request) Blocked by required conditions

Брокер и Collector принимают только серийный номер текущего leaf. Прогон показывает rehash, 429 до дорогого Argon2, отказ stranger, ротацию пароля worker и сохранность задания.
This commit is contained in:
2026-11-26 20:40:00 +03:00
parent 9de3b01659
commit 2d4c3163fa
16 changed files with 889 additions and 17 deletions
+13 -1
View File
@@ -2,7 +2,19 @@
set -eu
apk add --no-cache openssl >/dev/null
cd /work
serial_of() {
openssl x509 -in "$1" -noout -serial | awk -F= '{print tolower($2)}'
}
write_allows() {
openssl x509 -in lb-client.crt -outform DER | openssl dgst -sha256 -r | awk '{print $1}' > allowed-lb.sha256
serial_of api-client.crt > allowed-api.serial
serial_of worker-client.crt > allowed-worker.serial
}
if [ -f ca.crt ] && [ -f allowed-lb.sha256 ] && [ -f lb.pem ]; then
write_allows
echo "certificates already present"
exit 0
fi
@@ -70,7 +82,7 @@ openssl x509 -req -in /tmp/other-client.csr -CA other-ca.crt -CAkey other-ca.key
-out other-client.crt -days 7 -extfile /tmp/other-client.cnf >/dev/null 2>&1
cat other-client.crt other-client.key > other-client.pem
openssl x509 -in lb-client.crt -outform DER | openssl dgst -sha256 -r | awk '{print $1}' > allowed-lb.sha256
write_allows
find . -name '*.key' -exec chmod 644 {} \;
find . -name '*.pem' -exec chmod 644 {} \;
echo "certificates created"
+66
View File
@@ -0,0 +1,66 @@
#!/bin/sh
# Reissue one leaf from the existing lab CA. Does not print the key.
# Args: name cn eku san
# Optional env: NOT_BEFORE, NOT_AFTER as YYYYMMDDHHMMSSZ
set -eu
apk add --no-cache openssl >/dev/null
cd /work
name="$1"
cn="$2"
eku="$3"
san="$4"
test -f ca.key
test -f ca.crt
cat > "/tmp/${name}.cnf" <<EOF
[req]
distinguished_name=dn
prompt=no
[dn]
CN=${cn}
[ext]
subjectAltName=${san}
keyUsage=digitalSignature,keyEncipherment
extendedKeyUsage=${eku}
basicConstraints=CA:FALSE
EOF
openssl req -newkey rsa:2048 -nodes -keyout "${name}.key" -out "/tmp/${name}.csr" -subj "/CN=${cn}" >/dev/null 2>&1
if [ -n "${NOT_BEFORE:-}" ] || [ -n "${NOT_AFTER:-}" ]; then
mkdir -p /tmp/newcerts
: > /tmp/index.txt
echo 1000 > /tmp/serial
cat > /tmp/ca.cnf <<EOF
[ca]
default_ca=CA_default
[CA_default]
database=/tmp/index.txt
serial=/tmp/serial
new_certs_dir=/tmp/newcerts
certificate=/work/ca.crt
private_key=/work/ca.key
default_md=sha256
policy=policy_any
copy_extensions=none
unique_subject=no
[policy_any]
commonName=supplied
EOF
openssl ca -batch -notext -config /tmp/ca.cnf \
-in "/tmp/${name}.csr" -out "${name}.crt" \
-startdate "${NOT_BEFORE:-20200101000000Z}" -enddate "${NOT_AFTER:-20200102000000Z}" \
-extfile "/tmp/${name}.cnf" -extensions ext >/dev/null 2>&1
else
openssl x509 -req -in "/tmp/${name}.csr" -CA ca.crt -CAkey ca.key -CAcreateserial \
-out "${name}.crt" -days 7 -extfile "/tmp/${name}.cnf" -extensions ext >/dev/null 2>&1
fi
cat "${name}.crt" "${name}.key" > "${name}.pem"
chmod 644 "${name}.key" "${name}.pem"
if [ "$name" = "lb-client" ]; then
openssl x509 -in lb-client.crt -outform DER | openssl dgst -sha256 -r | awk '{print $1}' > allowed-lb.sha256
fi
if [ "$name" = "api-client" ]; then
openssl x509 -in api-client.crt -noout -serial | awk -F= '{print tolower($2)}' > allowed-api.serial
fi
if [ "$name" = "worker-client" ]; then
openssl x509 -in worker-client.crt -noout -serial | awk -F= '{print tolower($2)}' > allowed-worker.serial
fi
echo "reissued $name"