blob: 0947fe0128b1a45967f9a431d10e8d8ba72af298 [file] [log] [blame]
William Lallemand1ac17682020-10-23 18:37:19 +02001#REGTEST_TYPE=devel
2
3# This reg-test uses the "set ssl cert" command to update a certificate over the CLI.
4# It requires socat to upload the certificate
5#
6# this check does 3 requests, the first one will use "www.test1.com" as SNI,
7# the second one with the same but that must fail and the third one will use
8# "localhost". Since vtest can't do SSL, we use haproxy as an SSL client with 2
9# chained listen section.
10#
11# If this test does not work anymore:
12# - Check that you have socat
13
14varnishtest "Test the 'set ssl cert' feature of the CLI with separate key and crt"
15#REQUIRE_VERSION=2.2
16#REQUIRE_OPTIONS=OPENSSL
Tim Duesterhus4ee192f2021-06-11 19:56:17 +020017feature cmd "command -v socat"
William Lallemand1ac17682020-10-23 18:37:19 +020018feature ignore_unknown_macro
19
20server s1 -repeat 3 {
21 rxreq
22 txresp
23} -start
24
25haproxy h1 -conf {
26 global
27 tune.ssl.default-dh-param 2048
Marcin Deranek310a2602021-07-13 19:04:24 +020028 tune.ssl.capture-buffer-size 1
William Lallemand1ac17682020-10-23 18:37:19 +020029 ssl-load-extra-del-ext
30 stats socket "${tmpdir}/h1/stats" level admin
31
32 defaults
33 mode http
34 option httplog
William Lallemand1ac17682020-10-23 18:37:19 +020035 log stderr local0 debug err
36 option logasap
37 timeout connect 100ms
38 timeout client 1s
39 timeout server 1s
40
41 listen clear-lst
42 bind "fd@${clearlst}"
43 balance roundrobin
44 retries 0 # 2nd SSL connection must fail so skip the retry
45 server s1 "${tmpdir}/ssl.sock" ssl verify none sni str(www.test1.com)
46 server s2 "${tmpdir}/ssl.sock" ssl verify none sni str(www.test1.com)
47 server s3 "${tmpdir}/ssl.sock" ssl verify none sni str(localhost)
48
49 listen ssl-lst
50 bind "${tmpdir}/ssl.sock" ssl crt ${testdir}/common.crt strict-sni
51
52 server s1 ${s1_addr}:${s1_port}
53} -start
54
55
56haproxy h1 -cli {
57 send "show ssl cert ${testdir}/common.crt"
58 expect ~ ".*SHA1 FingerPrint: 2195C9F0FD58470313013FC27C1B9CF9864BD1C6"
59}
60
61client c1 -connect ${h1_clearlst_sock} {
62 txreq
63 rxresp
64 expect resp.status == 200
65} -run
66
67shell {
68 printf "set ssl cert ${testdir}/common.crt <<\n$(cat ${testdir}/ecdsa.crt)\n\n" | socat "${tmpdir}/h1/stats" -
69 printf "set ssl cert ${testdir}/common.key <<\n$(cat ${testdir}/ecdsa.key)\n\n" | socat "${tmpdir}/h1/stats" -
70 echo "commit ssl cert ${testdir}/common.crt" | socat "${tmpdir}/h1/stats" -
71}
72
73haproxy h1 -cli {
74 send "show ssl cert ${testdir}/common.crt"
75 expect ~ ".*SHA1 FingerPrint: A490D069DBAFBEE66DE434BEC34030ADE8BCCBF1"
76}
77
78# check that the "www.test1.com" SNI was removed
79client c1 -connect ${h1_clearlst_sock} {
80 txreq
81 rxresp
82 expect resp.status == 503
83} -run
84
85client c1 -connect ${h1_clearlst_sock} {
86 txreq
87 rxresp
88 expect resp.status == 200
89} -run