interplane.Get Omega
Read in your language

omega-mv

Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.

Brought by drakestapleton

branch main Branches Tags History

omega-mv / om / tls / test / net / badssl.sh

49 lines · 2863 bytes Raw Blame History
1#!/bin/sh
2# SPDX-License-Identifier: Apache-2.0
3# badssl.com sweep for the om/tls client. Network: the badssl.com hosts only (plus 127.0.0.1).
4# usage: sh om/tls/test/net/badssl.sh OMC
5# Every host listed on https://badssl.com/ is tried live and, because badssl.com offers no TLS 1.3,
6# also by replaying its real certificate chain from a local TLS 1.3 server (badssl_run.py explains
7# the method); openssl verify on the same chain and trust store is the expected verdict.
8# Writes om/tls/test/net/badssl.tsv. Chains and the dashboard are cached in $BADSSL_CACHE
9# (default ../tlsverify-TlsSuites-ext/badssl next to the repository); delete it to refetch.
10# Final line: BADSSL PASS|FAIL refuse_ok=.. accept_ok=.. explained=.. unexplained=.. na=.. hosts=..
11set -u
12omc=${1:?usage: badssl.sh OMC}
13here=$(cd "$(dirname "$0")" && pwd)
14tls=$(cd "$here/../.." && pwd)
15root=$(cd "$tls/../.." && pwd)
16out="$root/build/tls/net-badssl"
17cache=${BADSSL_CACHE:-$root/../tlsverify-TlsSuites-ext/badssl}
18. "$here/lib.sh"
19rm -rf "$out"; mkdir -p "$out" "$cache/chains"
20echo "omc $(sha256sum "$omc" | cut -c1-64)"
21echo "tls.om $(sha256sum "$tls/tls.om" | cut -c1-64)"
22echo "python $(python3 -c 'import sys,cryptography;print(sys.version.split()[0],"cryptography",cryptography.__version__)') $(openssl version)"
23echo "store /etc/ssl/certs/ca-certificates.crt $(sha256sum /etc/ssl/certs/ca-certificates.crt | cut -c1-64)"
24if [ ! -s "$cache/dashboard.html" ]; then
25 curl -fsS --max-time 30 -o "$cache/dashboard.html" https://badssl.com/ || { echo "BADSSL FAIL refuse_ok=0 accept_ok=0 explained=0 unexplained=1 na=0 hosts=0"; exit 1; }
26fi
27echo "dashboard $(sha256sum "$cache/dashboard.html" | cut -c1-64) $(date -u -r "$cache/dashboard.html" +%Y-%m-%dT%H:%M:%SZ)"
28build client "$tls/tls.om" || { echo "BADSSL FAIL refuse_ok=0 accept_ok=0 explained=0 unexplained=1 na=0 hosts=0"; exit 1; }
29mkpki "$out/pki"
30cl="$out/client/bin"
31
32# the negotiation rows (cipher suite, key exchange, protocol) rest on what the client offers
33p=$(python3 -c 'import socket;s=socket.socket();s.bind(("127.0.0.1",0));print(s.getsockname()[1])')
34python3 "$here/hostile.py" "$p" "$out/pki" ch_policy > "$out/ch.log" 2>&1 &
35sp=$!
36sleep 0.5
37timeout 20 "$cl" localhost "$p" get 127.0.0.1 "$out/pki/root.pem" > /dev/null 2>&1
38wait $sp
39pol=$(grep '^SRV ch_policy' "$out/ch.log")
40echo "$pol"
41case "$pol" in *" bad=none") polok=1 ;; *) echo "FAIL ClientHello policy"; polok=0 ;; esac
42
43python3 "$here/badssl_run.py" "$cl" "$out/pki" "$cache/dashboard.html" "$cache/chains" "$here/badssl.tsv" > "$out/run.log" 2>&1
44rc=$?
45grep -v '^BADSSL ' "$out/run.log"
46final=$(grep '^BADSSL ' "$out/run.log")
47[ -n "$final" ] || final="BADSSL FAIL refuse_ok=0 accept_ok=0 explained=0 unexplained=1 na=0 hosts=0"
48if [ $rc = 0 ] && [ $polok = 1 ]; then echo "$final"; exit 0; fi
49echo "$final" | sed 's/^BADSSL PASS/BADSSL FAIL/'; exit 1