blob: 8dfc91a2dff27e4d9df6abc826ba99cdd432be60 [file] [log] [blame]
William Lallemand35201832021-04-02 15:23:14 +02001#REGTEST_TYPE=devel
2
3# This reg-test uses the "set ssl cert" command to update a multi-certificate
4# bundle over the CLI.
5# It requires socat to upload the certificate
6#
7# This regtests loads a multi-certificates bundle "cert1-example.com.pem"
8# composed of a .rsa and a .ecdsa
9#
10# After verifying that the RSA and ECDSA algorithms were avalailble with the
11# right certificate, the test changes the certificates and try new requests.
12#
13# If this test does not work anymore:
14# - Check that you have socat
15
16varnishtest "Test the 'set ssl cert' feature of the CLI with bundles"
17#REQUIRE_VERSION=2.3
18#REQUIRE_OPTIONS=OPENSSL
19#REQUIRE_BINARIES=socat
20feature ignore_unknown_macro
21
22server s1 -repeat 9 {
23 rxreq
24 txresp
25} -start
26
27haproxy h1 -conf {
28 global
29 tune.ssl.default-dh-param 2048
30 tune.ssl.capture-cipherlist-size 1
31 stats socket "${tmpdir}/h1/stats" level admin
32 crt-base ${testdir}
33
34 defaults
35 mode http
36 option httplog
37 ${no-htx} option http-use-htx
38 log stderr local0 debug err
39 option logasap
40 timeout connect 100ms
41 timeout client 1s
42 timeout server 1s
43
44 listen clear-lst
45 bind "fd@${clearlst}"
46 balance roundrobin
47
48 http-response set-header X-SSL-Server-SHA1 %[ssl_s_sha1,hex]
49
50 retries 0 # 2nd SSL connection must fail so skip the retry
51 server s1 "${tmpdir}/ssl.sock" ssl verify none sni str(example.com) force-tlsv12 ciphers ECDHE-RSA-AES128-GCM-SHA256
52 server s2 "${tmpdir}/ssl.sock" ssl verify none sni str(example.com) force-tlsv12 ciphers ECDHE-ECDSA-AES256-GCM-SHA384
53
54 server s3 "${tmpdir}/ssl.sock" ssl verify none sni str(example.com) force-tlsv12 ciphers ECDHE-RSA-AES128-GCM-SHA256
55 server s4 "${tmpdir}/ssl.sock" ssl verify none sni str(example.com) force-tlsv12 ciphers ECDHE-ECDSA-AES256-GCM-SHA384
56
57 listen ssl-lst
58 bind "${tmpdir}/ssl.sock" ssl crt ${testdir}/cert1-example.com.pem
59 server s1 ${s1_addr}:${s1_port}
60
61} -start
62
63
64haproxy h1 -cli {
65 send "show ssl cert ${testdir}/cert1-example.com.pem.rsa"
66 expect ~ ".*SHA1 FingerPrint: 94F720DACA71B8B1A0AC9BD48C65BA688FF047DE"
67 send "show ssl cert ${testdir}/cert1-example.com.pem.ecdsa"
68 expect ~ ".*SHA1 FingerPrint: C1BA055D452F92EB02D449F0498C289F50698300"
69}
70
71client c1 -connect ${h1_clearlst_sock} {
72# RSA
73 txreq
74 rxresp
75 expect resp.http.X-SSL-Server-SHA1 == "94F720DACA71B8B1A0AC9BD48C65BA688FF047DE"
76 expect resp.status == 200
77# ECDSA
78 txreq
79 rxresp
80 expect resp.http.X-SSL-Server-SHA1 == "C1BA055D452F92EB02D449F0498C289F50698300"
81 expect resp.status == 200
82} -run
83
84shell {
85 printf "set ssl cert ${testdir}/cert1-example.com.pem.rsa <<\n$(cat ${testdir}/cert2-example.com.pem.rsa)\n\n" | socat "${tmpdir}/h1/stats" -
86 echo "commit ssl cert ${testdir}/cert1-example.com.pem.rsa" | socat "${tmpdir}/h1/stats" -
87 printf "set ssl cert ${testdir}/cert1-example.com.pem.ecdsa <<\n$(cat ${testdir}/cert2-example.com.pem.ecdsa)\n\n" | socat "${tmpdir}/h1/stats" -
88 echo "commit ssl cert ${testdir}/cert1-example.com.pem.ecdsa" | socat "${tmpdir}/h1/stats" -
89}
90
91haproxy h1 -cli {
92 send "show ssl cert ${testdir}/cert1-example.com.pem.rsa"
93 expect ~ ".*SHA1 FingerPrint: ADC863817FC40C2A9CA913CE45C9A92232558F90"
94 send "show ssl cert ${testdir}/cert1-example.com.pem.ecdsa"
95 expect ~ ".*SHA1 FingerPrint: F49FFA446D072262445C197B85D2F400B3F58808"
96}
97
98client c1 -connect ${h1_clearlst_sock} {
99# RSA
100 txreq
101 rxresp
102 expect resp.http.X-SSL-Server-SHA1 == "ADC863817FC40C2A9CA913CE45C9A92232558F90"
103 expect resp.status == 200
104# ECDSA
105 txreq
106 rxresp
107 expect resp.http.X-SSL-Server-SHA1 == "F49FFA446D072262445C197B85D2F400B3F58808"
108 expect resp.status == 200
109} -run
110