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 |
| 25 | tune.ssl.capture-cipherlist-size 1 |
| 26 | crt-base ${testdir} |
| 27 | stats socket "${tmpdir}/h1/stats" level admin |
| 28 | |
| 29 | defaults |
| 30 | mode http |
| 31 | option httplog |
| 32 | ${no-htx} option http-use-htx |
| 33 | log stderr local0 debug err |
| 34 | option logasap |
| 35 | timeout connect 100ms |
| 36 | timeout client 1s |
| 37 | timeout server 1s |
| 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 |
| 50 | ${no-htx} option http-use-htx |
| 51 | bind "${tmpdir}/first-ssl.sock" ssl strict-sni crt-list ${testdir}/simple.crt-list |
| 52 | server s1 ${s1_addr}:${s1_port} |
| 53 | |
| 54 | listen second-ssl-fe |
| 55 | mode http |
| 56 | ${no-htx} option http-use-htx |
| 57 | bind "${tmpdir}/second-ssl.sock" ssl crt-list ${testdir}/localhost.crt-list |
| 58 | server s1 ${s1_addr}:${s1_port} |
| 59 | } -start |
| 60 | |
| 61 | client c1 -connect ${h1_clearlst_sock} { |
| 62 | txreq |
| 63 | rxresp |
| 64 | expect resp.http.X-SSL-Server-SHA1 == "2195C9F0FD58470313013FC27C1B9CF9864BD1C6" |
| 65 | expect resp.status == 200 |
| 66 | } -run |
| 67 | |
| 68 | client c1 -connect ${h1_clearlst_sock} { |
| 69 | txreq |
| 70 | rxresp |
| 71 | expect resp.http.X-SSL-Server-SHA1 == "A490D069DBAFBEE66DE434BEC34030ADE8BCCBF1" |
| 72 | expect resp.status == 200 |
| 73 | } -run |
| 74 | |
| 75 | haproxy h1 -cli { |
| 76 | send "del ssl crt-list ${testdir}/simple.crt-list ${testdir}/common.pem:2" |
| 77 | expect ~ "Entry '${testdir}/common.pem' deleted in crtlist '${testdir}/simple.crt-list'!" |
| 78 | } |
| 79 | |
| 80 | haproxy h1 -cli { |
| 81 | send "show ssl crt-list -n ${testdir}/simple.crt-list" |
| 82 | expect !~ "common.pem:2" |
| 83 | } |
| 84 | |
| 85 | # This connection should fail since the corresponding line was deleted from the crt-list |
| 86 | # and the strict-sni option is enabled. |
| 87 | client c1 -connect ${h1_clearlst_sock} { |
| 88 | txreq |
| 89 | rxresp |
| 90 | expect resp.status == 503 |
| 91 | } -run |
| 92 | |
| 93 | # We should not be able to delete the crt-list's first line since it is the |
| 94 | # default certificate of this bind line and the strict-sni option is not enabled. |
| 95 | haproxy h1 -cli { |
| 96 | send "del ssl crt-list ${testdir}/localhost.crt-list ${testdir}/common.pem:1" |
| 97 | expect ~ "Can't delete the entry: certificate '${testdir}/common.pem' cannot be deleted, it is used as default certificate by the following frontends:" |
| 98 | } |
| 99 | |
| 100 | # We should be able to delete any line of the crt-list since the strict-sni option is enabled. |
| 101 | haproxy h1 -cli { |
| 102 | send "del ssl crt-list ${testdir}/simple.crt-list ${testdir}/common.pem:1" |
| 103 | expect ~ "Entry '${testdir}/common.pem' deleted in crtlist '${testdir}/simple.crt-list'!" |
| 104 | } |