William Lallemand | d513644 | 2023-08-28 17:12:14 +0200 | [diff] [blame] | 1 | #REGTEST_TYPE=devel |
| 2 | |
| 3 | # This reg-test uses the "set ssl cert" command to update a certificate over the CLI. |
| 4 | # It requires socat to upload the certificate |
| 5 | # |
| 6 | # this check does 3 requests, the first one will use "www.test1.com" as SNI, |
| 7 | # the second one with the same but that must fail and the third one will use |
| 8 | # "localhost". Since vtest can't do SSL, we use haproxy as an SSL client with 2 |
| 9 | # chained listen section. |
| 10 | # |
| 11 | # This is the same as "set_ssl_cert_noext.vtc" but the .crt contains both the certificate and the key. |
| 12 | # |
| 13 | # If this test does not work anymore: |
| 14 | # - Check that you have socat |
| 15 | |
| 16 | varnishtest "Test the 'set ssl cert' feature of the CLI with separate key and crt" |
| 17 | #REQUIRE_VERSION=2.2 |
| 18 | #REQUIRE_OPTIONS=OPENSSL |
| 19 | feature cmd "command -v socat" |
| 20 | feature ignore_unknown_macro |
| 21 | |
| 22 | server s1 -repeat 3 { |
| 23 | rxreq |
| 24 | txresp |
| 25 | } -start |
| 26 | |
| 27 | haproxy h1 -conf { |
| 28 | global |
| 29 | tune.ssl.default-dh-param 2048 |
| 30 | tune.ssl.capture-buffer-size 1 |
| 31 | stats socket "${tmpdir}/h1/stats" level admin |
| 32 | |
| 33 | defaults |
| 34 | mode http |
| 35 | option httplog |
| 36 | retries 0 |
| 37 | log stderr local0 debug err |
| 38 | option logasap |
| 39 | timeout connect "${HAPROXY_TEST_TIMEOUT-5s}" |
| 40 | timeout client "${HAPROXY_TEST_TIMEOUT-5s}" |
| 41 | timeout server "${HAPROXY_TEST_TIMEOUT-5s}" |
| 42 | |
| 43 | listen clear-lst |
| 44 | bind "fd@${clearlst}" |
| 45 | balance roundrobin |
| 46 | retries 0 # 2nd SSL connection must fail so skip the retry |
| 47 | server s1 "${tmpdir}/ssl.sock" ssl verify none sni str(www.test1.com) |
| 48 | server s2 "${tmpdir}/ssl.sock" ssl verify none sni str(www.test1.com) |
| 49 | server s3 "${tmpdir}/ssl.sock" ssl verify none sni str(localhost) |
| 50 | |
| 51 | listen ssl-lst |
| 52 | bind "${tmpdir}/ssl.sock" ssl crt ${testdir}/bug-2265.crt strict-sni |
| 53 | |
| 54 | server s1 ${s1_addr}:${s1_port} |
| 55 | } -start |
| 56 | |
| 57 | |
| 58 | haproxy h1 -cli { |
| 59 | send "show ssl cert ${testdir}/bug-2265.crt" |
| 60 | expect ~ ".*SHA1 FingerPrint: 2195C9F0FD58470313013FC27C1B9CF9864BD1C6" |
| 61 | } |
| 62 | |
| 63 | client c1 -connect ${h1_clearlst_sock} { |
| 64 | txreq |
| 65 | rxresp |
| 66 | expect resp.status == 200 |
| 67 | } -run |
| 68 | |
| 69 | shell { |
| 70 | printf "set ssl cert ${testdir}/bug-2265.crt <<\n$(cat ${testdir}/ecdsa.pem)\n\n" | socat "${tmpdir}/h1/stats" - |
| 71 | echo "commit ssl cert ${testdir}/bug-2265.crt" | socat "${tmpdir}/h1/stats" - |
| 72 | } |
| 73 | |
| 74 | haproxy h1 -cli { |
| 75 | send "show ssl cert ${testdir}/bug-2265.crt" |
| 76 | expect ~ ".*SHA1 FingerPrint: A490D069DBAFBEE66DE434BEC34030ADE8BCCBF1" |
| 77 | } |
| 78 | |
| 79 | # check that the "www.test1.com" SNI was removed |
| 80 | client c1 -connect ${h1_clearlst_sock} { |
| 81 | txreq |
| 82 | rxresp |
| 83 | expect resp.status == 503 |
| 84 | } -run |
| 85 | |
| 86 | client c1 -connect ${h1_clearlst_sock} { |
| 87 | txreq |
| 88 | rxresp |
| 89 | expect resp.status == 200 |
| 90 | } -run |