blob: 84854a38b6bf07221bbdbfd2e314a856879349ea [file] [log] [blame]
William Lallemandacd546b2021-12-30 14:57:32 +01001#REGTEST_TYPE=bug
2# Test if a certicate can be dynamically updated once a server which used it
3# was removed.
4#
5varnishtest "Delete server via cli and update certificates"
6
7feature ignore_unknown_macro
8
9#REQUIRE_VERSION=2.4
10#REQUIRE_OPTIONS=OPENSSL
11feature cmd "command -v socat"
12
13# static server
14server s1 -repeat 3 {
15 rxreq
16 txresp \
17 -body "resp from s1"
18} -start
19
20haproxy h1 -conf {
21 global
22 stats socket "${tmpdir}/h1/stats" level admin
23
24 defaults
25 mode http
26 timeout connect "${HAPROXY_TEST_TIMEOUT-5s}"
27 timeout client "${HAPROXY_TEST_TIMEOUT-5s}"
28 timeout server "${HAPROXY_TEST_TIMEOUT-5s}"
29
30 frontend fe
31 bind "fd@${feS}"
32 default_backend test
33
34 backend test
35 server s1 "${tmpdir}/ssl.sock" ssl verify none crt "${testdir}/client1.pem"
36 server s2 "${tmpdir}/ssl.sock" ssl verify none crt "${testdir}/client1.pem"
37 server s3 "${tmpdir}/ssl.sock" ssl verify none crt "${testdir}/client1.pem"
38
39
40 listen ssl-lst
41 bind "${tmpdir}/ssl.sock" ssl crt "${testdir}/common.pem"
42 server s1 ${s1_addr}:${s1_port}
43
44} -start
45
46
47haproxy h1 -cli {
48 send "show ssl cert ${testdir}/client1.pem"
49 expect ~ ".*SHA1 FingerPrint: D9C3BAE37EA5A7EDB7B3C9BDD4DCB2FE58A412E4"
50}
51client c1 -connect ${h1_feS_sock} {
52 txreq
53 rxresp
54 expect resp.body == "resp from s1"
55} -run
56
57haproxy h1 -cli {
58 send "show ssl cert ${testdir}/client1.pem"
59 expect ~ ".*SHA1 FingerPrint: D9C3BAE37EA5A7EDB7B3C9BDD4DCB2FE58A412E4"
60}
61
62## delete the servers
63haproxy h1 -cli {
64 send "disable server test/s1"
65 expect ~ ".*"
66 send "disable server test/s2"
67 expect ~ ".*"
68 send "disable server test/s3"
69 expect ~ ".*"
70
71 # valid command
72 send "experimental-mode on; del server test/s1"
73 expect ~ "Server deleted."
74 send "experimental-mode on; del server test/s2"
75 expect ~ "Server deleted."
76 send "experimental-mode on; del server test/s3"
77 expect ~ "Server deleted."
78}
79
80# Replace certificate with an expired one
81shell {
82 printf "set ssl cert ${testdir}/client1.pem <<\n$(cat ${testdir}/client2_expired.pem)\n\n" | socat "${tmpdir}/h1/stats" -
83 echo "commit ssl cert ${testdir}/client1.pem" | socat "${tmpdir}/h1/stats" -
84}
85
86haproxy h1 -cli {
87 send "show ssl cert ${testdir}/client1.pem"
88 expect ~ ".*SHA1 FingerPrint: C625EB01A0A660294B9D7F44C5CEEE5AFC495BE4"
89}
90
91haproxy h1 -cli {
92 send "show ssl cert ${testdir}/client1.pem"
93 expect ~ ".*Status: Unused"
94}
95
96haproxy h1 -cli {
97 send "experimental-mode on; add server test/s1 ${tmpdir}/ssl.sock ssl verify none crt ${testdir}/client1.pem"
98 expect ~ "New server registered."
99 send "enable server test/s1"
100 expect ~ ".*"
101 send "show ssl cert ${testdir}/client1.pem"
102 expect ~ ".*Status: Used"
103}
104
105
106# check that servers are active
107client c1 -connect ${h1_feS_sock} {
108 txreq
109 rxresp
110 expect resp.body == "resp from s1"
111} -run
112