Remi Tricot-Le Breton | bc2c386 | 2021-03-26 10:47:50 +0100 | [diff] [blame] | 1 | #REGTEST_TYPE=devel |
| 2 | |
| 3 | # This reg-test uses the "del ssl crt-list" command to remove a line from a crt-list. |
| 4 | |
| 5 | # It performs three requests towards a frontend that uses simple.crt-list. |
| 6 | # Between the second and third requests, a line is deleted from the crt-list, |
| 7 | # which makes the third request fail since it would have used the deleted line |
| 8 | # and the strict-sni option is enabled on the frontend. |
| 9 | # Another test is performed as well. A line corresponding to the default instance |
| 10 | # of a frontend that does not have the strict-sni option enabled cannot be deleted. |
| 11 | |
| 12 | varnishtest "Test the 'del ssl crt-list' feature of the CLI" |
| 13 | #REQUIRE_VERSION=2.2 |
| 14 | #REQUIRE_OPTIONS=OPENSSL |
| 15 | feature ignore_unknown_macro |
| 16 | |
| 17 | server s1 -repeat 2 { |
| 18 | rxreq |
| 19 | txresp |
| 20 | } -start |
| 21 | |
| 22 | haproxy h1 -conf { |
| 23 | global |
| 24 | tune.ssl.default-dh-param 2048 |
Marcin Deranek | 310a260 | 2021-07-13 19:04:24 +0200 | [diff] [blame] | 25 | tune.ssl.capture-buffer-size 1 |
Remi Tricot-Le Breton | bc2c386 | 2021-03-26 10:47:50 +0100 | [diff] [blame] | 26 | crt-base ${testdir} |
| 27 | stats socket "${tmpdir}/h1/stats" level admin |
| 28 | |
| 29 | defaults |
| 30 | mode http |
| 31 | option httplog |
Willy Tarreau | f673923 | 2021-11-18 17:46:22 +0100 | [diff] [blame^] | 32 | retries 0 |
Remi Tricot-Le Breton | bc2c386 | 2021-03-26 10:47:50 +0100 | [diff] [blame] | 33 | log stderr local0 debug err |
| 34 | option logasap |
Willy Tarreau | f673923 | 2021-11-18 17:46:22 +0100 | [diff] [blame^] | 35 | timeout connect "${HAPROXY_TEST_TIMEOUT-5s}" |
| 36 | timeout client "${HAPROXY_TEST_TIMEOUT-5s}" |
| 37 | timeout server "${HAPROXY_TEST_TIMEOUT-5s}" |
Remi Tricot-Le Breton | bc2c386 | 2021-03-26 10:47:50 +0100 | [diff] [blame] | 38 | |
| 39 | |
| 40 | listen clear-lst |
| 41 | bind "fd@${clearlst}" |
| 42 | balance roundrobin |
| 43 | http-response set-header X-SSL-Server-SHA1 %[ssl_s_sha1,hex] |
| 44 | server s1 "${tmpdir}/first-ssl.sock" ssl verify none sni str(record2.bug940.domain.tld) |
| 45 | server s2 "${tmpdir}/first-ssl.sock" ssl verify none sni str(record3.bug940.domain.tld) |
| 46 | server s3 "${tmpdir}/first-ssl.sock" ssl verify none sni str(record2.bug940.domain.tld) |
| 47 | |
| 48 | listen first-ssl-fe |
| 49 | mode http |
Remi Tricot-Le Breton | bc2c386 | 2021-03-26 10:47:50 +0100 | [diff] [blame] | 50 | bind "${tmpdir}/first-ssl.sock" ssl strict-sni crt-list ${testdir}/simple.crt-list |
| 51 | server s1 ${s1_addr}:${s1_port} |
| 52 | |
| 53 | listen second-ssl-fe |
| 54 | mode http |
Remi Tricot-Le Breton | bc2c386 | 2021-03-26 10:47:50 +0100 | [diff] [blame] | 55 | bind "${tmpdir}/second-ssl.sock" ssl crt-list ${testdir}/localhost.crt-list |
| 56 | server s1 ${s1_addr}:${s1_port} |
| 57 | } -start |
| 58 | |
| 59 | client c1 -connect ${h1_clearlst_sock} { |
| 60 | txreq |
| 61 | rxresp |
| 62 | expect resp.http.X-SSL-Server-SHA1 == "2195C9F0FD58470313013FC27C1B9CF9864BD1C6" |
| 63 | expect resp.status == 200 |
| 64 | } -run |
| 65 | |
| 66 | client c1 -connect ${h1_clearlst_sock} { |
| 67 | txreq |
| 68 | rxresp |
| 69 | expect resp.http.X-SSL-Server-SHA1 == "A490D069DBAFBEE66DE434BEC34030ADE8BCCBF1" |
| 70 | expect resp.status == 200 |
| 71 | } -run |
| 72 | |
| 73 | haproxy h1 -cli { |
| 74 | send "del ssl crt-list ${testdir}/simple.crt-list ${testdir}/common.pem:2" |
| 75 | expect ~ "Entry '${testdir}/common.pem' deleted in crtlist '${testdir}/simple.crt-list'!" |
| 76 | } |
| 77 | |
| 78 | haproxy h1 -cli { |
| 79 | send "show ssl crt-list -n ${testdir}/simple.crt-list" |
| 80 | expect !~ "common.pem:2" |
| 81 | } |
| 82 | |
| 83 | # This connection should fail since the corresponding line was deleted from the crt-list |
| 84 | # and the strict-sni option is enabled. |
| 85 | client c1 -connect ${h1_clearlst_sock} { |
| 86 | txreq |
| 87 | rxresp |
| 88 | expect resp.status == 503 |
| 89 | } -run |
| 90 | |
| 91 | # We should not be able to delete the crt-list's first line since it is the |
| 92 | # default certificate of this bind line and the strict-sni option is not enabled. |
| 93 | haproxy h1 -cli { |
| 94 | send "del ssl crt-list ${testdir}/localhost.crt-list ${testdir}/common.pem:1" |
| 95 | expect ~ "Can't delete the entry: certificate '${testdir}/common.pem' cannot be deleted, it is used as default certificate by the following frontends:" |
| 96 | } |
| 97 | |
| 98 | # We should be able to delete any line of the crt-list since the strict-sni option is enabled. |
| 99 | haproxy h1 -cli { |
| 100 | send "del ssl crt-list ${testdir}/simple.crt-list ${testdir}/common.pem:1" |
| 101 | expect ~ "Entry '${testdir}/common.pem' deleted in crtlist '${testdir}/simple.crt-list'!" |
| 102 | } |