Artifact 2330ef73c4cf809d4448a443345a24601631b94b17c07346d678c6abb885c6bf:
- File
test/https_certs.sh
— part of check-in
[70d6eed709]
at
2026-11-18 18:37:27
on branch trunk
— The https tests make their certificate files private, so they pass on any umask
The forge's runner creates files with umask 002, so the certificate files and folders the tests made were group-writable, and the new check on certificate files rightly refused them: 10 unit checks and most https cases failed there. Every certificate the tests make is now 0644 in a 0755 folder, so the tests no longer depend on the umask. The check is unchanged. A new case, under umask 002, shows a group-writable CA file refused and the same file accepted after chmod 644.
In the coverage build only, a name-lookup child killed while writing its profile could corrupt it; the child now writes its own file and renames it when whole.
3792 unit checks (was 3788) and 172 https cases (was 170), with every other suite unchanged, under clang, under gcc 16, with no user name set and umask 002, and under umask 027, in one run of make gate. 100% coverage in all 34 source files. (user: dmestas, size: 1794) [annotate] [blame] [check-ins using]
#!/bin/sh # Certificates for test/https.sh, made fresh in DIR each run and never kept: # ca1 (the trusted CA), ca2 (a CA nobody trusts), leaf (localhost, from ca1), # leafca2 (localhost, from ca2), rsa (localhost, an RSA key, from ca1), and # where this openssl can backdate one, expired (localhost, from ca1, ended in # 2025). ECDSA P-256 but for rsa. Each NAME.chain.pem is the leaf and its CA. # usage: https_certs.sh DIR (needs openssl) set -eu mkdir -p "$1" # Modes of their own, whatever the umask: suit trusts no certificate file # that group or others can write, nor one in such a folder. chmod 755 "$1" cd "$1" mkca() { openssl ecparam -name prime256v1 -genkey -noout -out "$1.key" 2>/dev/null openssl req -x509 -new -key "$1.key" -sha256 -days 30 -subj "/CN=suit test $1" \ -addext basicConstraints=critical,CA:TRUE -addext keyUsage=critical,keyCertSign -out "$1.pem" 2>/dev/null } mkca ca1 mkca ca2 printf 'subjectAltName=DNS:localhost\nbasicConstraints=CA:FALSE\nkeyUsage=digitalSignature,keyEncipherment\nextendedKeyUsage=serverAuth\n' > ext.cnf mkleaf() { # NAME CA [x509 options] n=$1 ca=$2 shift 2 if [ "$n" = rsa ]; then openssl genrsa -out "$n.key" 2048 2>/dev/null else openssl ecparam -name prime256v1 -genkey -noout -out "$n.key" 2>/dev/null fi openssl req -new -key "$n.key" -subj "/CN=localhost" -out "$n.csr" 2>/dev/null openssl x509 -req -in "$n.csr" -CA "$ca.pem" -CAkey "$ca.key" -CAcreateserial -sha256 \ -extfile ext.cnf "$@" -out "$n.crt" 2>/dev/null cat "$n.crt" "$ca.pem" > "$n.chain.pem" } mkleaf leaf ca1 -days 30 mkleaf leafca2 ca2 -days 30 mkleaf rsa ca1 -days 30 mkleaf expired ca1 -not_before 20250101000000Z -not_after 20250201000000Z || rm -f expired.* chmod 644 ./*.pem ./*.crt