blob: 4815e2de75a2b8b139ac29546dd5f0e9241731c5 [file] [log] [blame]
Remi Tricot-Le Bretonbc2c3862021-03-26 10:47:50 +01001#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
12varnishtest "Test the 'del ssl crt-list' feature of the CLI"
13#REQUIRE_VERSION=2.2
14#REQUIRE_OPTIONS=OPENSSL
15feature ignore_unknown_macro
16
17server s1 -repeat 2 {
18 rxreq
19 txresp
20} -start
21
22haproxy h1 -conf {
23 global
24 tune.ssl.default-dh-param 2048
Marcin Deranek310a2602021-07-13 19:04:24 +020025 tune.ssl.capture-buffer-size 1
Remi Tricot-Le Bretonbc2c3862021-03-26 10:47:50 +010026 crt-base ${testdir}
27 stats socket "${tmpdir}/h1/stats" level admin
28
29 defaults
30 mode http
31 option httplog
Remi Tricot-Le Bretonbc2c3862021-03-26 10:47:50 +010032 log stderr local0 debug err
33 option logasap
34 timeout connect 100ms
35 timeout client 1s
36 timeout server 1s
37
38
39 listen clear-lst
40 bind "fd@${clearlst}"
41 balance roundrobin
42 http-response set-header X-SSL-Server-SHA1 %[ssl_s_sha1,hex]
43 server s1 "${tmpdir}/first-ssl.sock" ssl verify none sni str(record2.bug940.domain.tld)
44 server s2 "${tmpdir}/first-ssl.sock" ssl verify none sni str(record3.bug940.domain.tld)
45 server s3 "${tmpdir}/first-ssl.sock" ssl verify none sni str(record2.bug940.domain.tld)
46
47 listen first-ssl-fe
48 mode http
Remi Tricot-Le Bretonbc2c3862021-03-26 10:47:50 +010049 bind "${tmpdir}/first-ssl.sock" ssl strict-sni crt-list ${testdir}/simple.crt-list
50 server s1 ${s1_addr}:${s1_port}
51
52 listen second-ssl-fe
53 mode http
Remi Tricot-Le Bretonbc2c3862021-03-26 10:47:50 +010054 bind "${tmpdir}/second-ssl.sock" ssl crt-list ${testdir}/localhost.crt-list
55 server s1 ${s1_addr}:${s1_port}
56} -start
57
58client c1 -connect ${h1_clearlst_sock} {
59 txreq
60 rxresp
61 expect resp.http.X-SSL-Server-SHA1 == "2195C9F0FD58470313013FC27C1B9CF9864BD1C6"
62 expect resp.status == 200
63} -run
64
65client c1 -connect ${h1_clearlst_sock} {
66 txreq
67 rxresp
68 expect resp.http.X-SSL-Server-SHA1 == "A490D069DBAFBEE66DE434BEC34030ADE8BCCBF1"
69 expect resp.status == 200
70} -run
71
72haproxy h1 -cli {
73 send "del ssl crt-list ${testdir}/simple.crt-list ${testdir}/common.pem:2"
74 expect ~ "Entry '${testdir}/common.pem' deleted in crtlist '${testdir}/simple.crt-list'!"
75}
76
77haproxy h1 -cli {
78 send "show ssl crt-list -n ${testdir}/simple.crt-list"
79 expect !~ "common.pem:2"
80}
81
82# This connection should fail since the corresponding line was deleted from the crt-list
83# and the strict-sni option is enabled.
84client c1 -connect ${h1_clearlst_sock} {
85 txreq
86 rxresp
87 expect resp.status == 503
88} -run
89
90# We should not be able to delete the crt-list's first line since it is the
91# default certificate of this bind line and the strict-sni option is not enabled.
92haproxy h1 -cli {
93 send "del ssl crt-list ${testdir}/localhost.crt-list ${testdir}/common.pem:1"
94 expect ~ "Can't delete the entry: certificate '${testdir}/common.pem' cannot be deleted, it is used as default certificate by the following frontends:"
95}
96
97# We should be able to delete any line of the crt-list since the strict-sni option is enabled.
98haproxy h1 -cli {
99 send "del ssl crt-list ${testdir}/simple.crt-list ${testdir}/common.pem:1"
100 expect ~ "Entry '${testdir}/common.pem' deleted in crtlist '${testdir}/simple.crt-list'!"
101}