| 1 | #!/bin/sh |
| 2 | # Exercise the release BusyBox applet and the installed TLS helper inside Vinix. |
| 3 | set -eu |
| 4 | export PATH=/bin:/usr/bin:/sbin:/usr/sbin HOME=/tmp LC_ALL=C |
| 5 | unset http_proxy https_proxy HTTP_PROXY HTTPS_PROXY ALL_PROXY SSL_CERT_FILE SSL_CERT_DIR |
| 6 | phase=identity |
| 7 | server= |
| 8 | finish() { |
| 9 | status=$? |
| 10 | if [ -n "$server" ]; then kill "$server" 2>/dev/null || true; fi |
| 11 | if [ "$status" -ne 0 ]; then echo "VPAC WGET FAIL at $phase with status $status"; fi |
| 12 | /sbin/poweroff -f |
| 13 | } |
| 14 | trap finish EXIT |
| 15 | test "$(uname -o)" = Vinix |
| 16 | test -x /usr/bin/ssl_client |
| 17 | mkdir -p /tmp/wget/empty |
| 18 | cd /tmp/wget |
| 19 | printf '\n127.0.0.1 vinix.test wrong.test\n' >>/etc/hosts |
| 20 | printf 'Signed Vinix networking packages\n' >body.txt |
| 21 | openssl req -x509 -newkey ec -pkeyopt ec_paramgen_curve:P-256 -nodes -days 1 \ |
| 22 | -subj /CN=vinix.test -addext subjectAltName=DNS:vinix.test -keyout key.pem -out cert.pem |
| 23 | openssl s_server -accept 127.0.0.1:21443 -cert cert.pem -key key.pem -WWW >server.log 2>&1 & |
| 24 | server=$! |
| 25 | |
| 26 | phase=trusted-peer |
| 27 | url=https://vinix.test:21443/body.txt |
| 28 | tries=0 |
| 29 | until SSL_CERT_FILE="$PWD/cert.pem" SSL_CERT_DIR="$PWD/empty" \ |
| 30 | /bin/busybox wget -T 5 -O received "$url" >client.log 2>&1; do |
| 31 | tries=$((tries + 1)) |
| 32 | if [ "$tries" -ge 5 ]; then cat client.log server.log; exit 1; fi |
| 33 | sleep 1 |
| 34 | done |
| 35 | cmp body.txt received |
| 36 | |
| 37 | phase=untrusted-ca |
| 38 | if /bin/busybox wget -T 5 -O rejected "$url" >client.log 2>&1; then exit 1; fi |
| 39 | cat client.log |
| 40 | grep -Eiq 'certificate verify failed|certificate verification failed' client.log |
| 41 | test ! -s rejected |
| 42 | |
| 43 | phase=system-store |
| 44 | mkdir -p /usr/local/share/ca-certificates |
| 45 | cp cert.pem /usr/local/share/ca-certificates/vinix-fixture.crt |
| 46 | update-ca-certificates |
| 47 | /bin/busybox wget -T 5 -O received "$url" |
| 48 | cmp body.txt received |
| 49 | |
| 50 | phase=wrong-hostname |
| 51 | if /bin/busybox wget -T 5 -O wrong https://wrong.test:21443/body.txt >client.log 2>&1; then exit 1; fi |
| 52 | cat client.log |
| 53 | grep -Eiq 'hostname mismatch|certificate verify failed|certificate verification failed' client.log |
| 54 | test ! -s wrong |
| 55 | echo 'VPAC FIXTURE GUEST PASS' |
| 56 | |