William Lallemand | acd546b | 2021-12-30 14:57:32 +0100 | [diff] [blame^] | 1 | #REGTEST_TYPE=bug |
| 2 | # Test if a certicate can be dynamically updated once a server which used it |
| 3 | # was removed. |
| 4 | # |
| 5 | varnishtest "Delete server via cli and update certificates" |
| 6 | |
| 7 | feature ignore_unknown_macro |
| 8 | |
| 9 | #REQUIRE_VERSION=2.4 |
| 10 | #REQUIRE_OPTIONS=OPENSSL |
| 11 | feature cmd "command -v socat" |
| 12 | |
| 13 | # static server |
| 14 | server s1 -repeat 3 { |
| 15 | rxreq |
| 16 | txresp \ |
| 17 | -body "resp from s1" |
| 18 | } -start |
| 19 | |
| 20 | haproxy 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 | |
| 47 | haproxy h1 -cli { |
| 48 | send "show ssl cert ${testdir}/client1.pem" |
| 49 | expect ~ ".*SHA1 FingerPrint: D9C3BAE37EA5A7EDB7B3C9BDD4DCB2FE58A412E4" |
| 50 | } |
| 51 | client c1 -connect ${h1_feS_sock} { |
| 52 | txreq |
| 53 | rxresp |
| 54 | expect resp.body == "resp from s1" |
| 55 | } -run |
| 56 | |
| 57 | haproxy h1 -cli { |
| 58 | send "show ssl cert ${testdir}/client1.pem" |
| 59 | expect ~ ".*SHA1 FingerPrint: D9C3BAE37EA5A7EDB7B3C9BDD4DCB2FE58A412E4" |
| 60 | } |
| 61 | |
| 62 | ## delete the servers |
| 63 | haproxy 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 |
| 81 | shell { |
| 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 | |
| 86 | haproxy h1 -cli { |
| 87 | send "show ssl cert ${testdir}/client1.pem" |
| 88 | expect ~ ".*SHA1 FingerPrint: C625EB01A0A660294B9D7F44C5CEEE5AFC495BE4" |
| 89 | } |
| 90 | |
| 91 | haproxy h1 -cli { |
| 92 | send "show ssl cert ${testdir}/client1.pem" |
| 93 | expect ~ ".*Status: Unused" |
| 94 | } |
| 95 | |
| 96 | haproxy 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 |
| 107 | client c1 -connect ${h1_feS_sock} { |
| 108 | txreq |
| 109 | rxresp |
| 110 | expect resp.body == "resp from s1" |
| 111 | } -run |
| 112 | |