blob: 11abdafdd0b2d11fbededa124c5262eb2ff9dc19 [file] [log] [blame]
William Lallemanda1e832b2021-04-02 17:01:25 +02001#REGTEST_TYPE=broken
William Lallemand35201832021-04-02 15:23:14 +02002
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
William Lallemanda1e832b2021-04-02 17:01:25 +020015# - Check that you have at least OpenSSL 1.1.0
William Lallemand35201832021-04-02 15:23:14 +020016
17varnishtest "Test the 'set ssl cert' feature of the CLI with bundles"
18#REQUIRE_VERSION=2.3
19#REQUIRE_OPTIONS=OPENSSL
Tim Duesterhus4ee192f2021-06-11 19:56:17 +020020feature cmd "command -v socat"
William Lallemand35201832021-04-02 15:23:14 +020021feature ignore_unknown_macro
22
23server s1 -repeat 9 {
24 rxreq
25 txresp
26} -start
27
28haproxy h1 -conf {
29 global
30 tune.ssl.default-dh-param 2048
Marcin Deranek310a2602021-07-13 19:04:24 +020031 tune.ssl.capture-buffer-size 1
William Lallemand35201832021-04-02 15:23:14 +020032 stats socket "${tmpdir}/h1/stats" level admin
33 crt-base ${testdir}
34
35 defaults
36 mode http
37 option httplog
William Lallemand35201832021-04-02 15:23:14 +020038 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