blob: 71692d2bd5c1d51a8449efc8429374b42326f4ff [file] [log] [blame]
William Lallemand2f52fdb2021-09-30 11:19:29 +02001#REGTEST_TYPE=devel
2
3# broken with BoringSSL.
Remi Tricot-Le Breton2a77c622021-06-10 13:51:16 +02004
5# This reg-test uses the "show ssl ocsp-response" command to display the details
6# of the OCSP responses used by HAProxy.
7# It also uses the new special cases of the "show ssl cert" command, where an OCSP
8# extension is provided to the certificate name (with or without preceding * for an
9# ongoing transaction).
10#
11# It uses the show_ocsp_server.pem server certificate, signed off by set_cafile_rootCA.crt,
12# which has two OCSP responses, show_ocsp_server.pem.ocsp which is loaded by default and in
13# which it is valid, and show_ocsp_server.pem.ocsp.revoked in which it is revoked.
14# The OSCP response is updated through the two means available in the CLI, the
15# "set ssl ocsp-response" command and the update through a "set ssl cert foo.ocsp".
16#
17# It requires socat to upload the new OCSP responses.
18#
19# If this test does not work anymore:
20# - Check that you have socat
21
22varnishtest "Test the 'show ssl ocsp-response' and 'show ssl cert foo.pem.ocsp' features of the CLI"
Tim Duesterhus5efc48d2021-06-11 19:56:15 +020023feature cmd "$HAPROXY_PROGRAM -cc 'version_atleast(2.5-dev0)'"
Ilya Shipitsin8de3eff2022-01-31 09:49:47 +050024feature cmd "$HAPROXY_PROGRAM -cc 'feature(OPENSSL) && !ssllib_name_startswith(BoringSSL)'"
William Lallemandf5429412021-09-30 18:45:18 +020025feature cmd "command -v socat && command -v openssl"
Remi Tricot-Le Breton2a77c622021-06-10 13:51:16 +020026feature ignore_unknown_macro
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
Remi Tricot-Le Breton2a77c622021-06-10 13:51:16 +020032 stats socket "${tmpdir}/h1/stats" level admin
33
34 defaults
35 mode http
36 option httplog
37 log stderr local0 debug err
38 option logasap
Willy Tarreauf6739232021-11-18 17:46:22 +010039 timeout connect "${HAPROXY_TEST_TIMEOUT-5s}"
40 timeout client "${HAPROXY_TEST_TIMEOUT-5s}"
41 timeout server "${HAPROXY_TEST_TIMEOUT-5s}"
Remi Tricot-Le Breton2a77c622021-06-10 13:51:16 +020042
43 listen clear-lst
44 bind "fd@${clearlst}"
45 server s1 "${tmpdir}/ssl.sock" ssl ca-file ${testdir}/set_cafile_rootCA.crt verify none
46
47 listen ssl-lst
48 # crt: certificate of the server
49 # ca-file: CA used for client authentication request
50 bind "${tmpdir}/ssl.sock" ssl crt ${testdir}/show_ocsp_server.pem ca-file ${testdir}/set_cafile_rootCA.crt verify none crt-ignore-err all
51 http-response add-header X-SSL-Client-Verify %[ssl_c_verify]
52 server s1 ${s1_addr}:${s1_port}
53} -start
54
55
56# Test the "show ssl ocsp-response" command
57haproxy h1 -cli {
58 send "show ssl ocsp-response"
59 expect ~ "Certificate ID key : 303b300906052b0e03021a050004148a83e0060faff709ca7e9b95522a2e81635fda0a0414f652b0e435d5ea923851508f0adbe92d85de007a0202100f"
60
61 send "show ssl ocsp-response 303b300906052b0e03021a050004148a83e0060faff709ca7e9b95522a2e81635fda0a0414f652b0e435d5ea923851508f0adbe92d85de007a0202100f"
62 expect ~ "Responder Id: C = FR, O = HAProxy Technologies, CN = ocsp.haproxy.com"
63 send "show ssl ocsp-response 303b300906052b0e03021a050004148a83e0060faff709ca7e9b95522a2e81635fda0a0414f652b0e435d5ea923851508f0adbe92d85de007a0202100f"
64 expect ~ "Cert Status: good"
65}
66
Remi Tricot-Le Bretondafc0682023-03-13 15:56:34 +010067# Test the "show ssl ocsp-response" command with a certificate path as parameter
68shell {
69 ocsp_response=$(echo "show ssl ocsp-response ${testdir}/show_ocsp_server.pem" | socat "${tmpdir}/h1/stats" -)
70
71 echo "$ocsp_response" | grep "Responder Id: C = FR, O = HAProxy Technologies, CN = ocsp.haproxy.com" &&
72 echo "$ocsp_response" | grep "Cert Status: good"
73}
74
Remi Tricot-Le Breton2a77c622021-06-10 13:51:16 +020075# Test the "show ssl cert foo.pem.ocsp" command
76haproxy h1 -cli {
77 send "show ssl cert"
78 expect ~ ".*show_ocsp_server.pem"
79
80 send "show ssl cert ${testdir}/show_ocsp_server.pem"
81 expect ~ "Serial: 100F"
82 send "show ssl cert ${testdir}/show_ocsp_server.pem"
83 expect ~ "OCSP Response Key: 303b300906052b0e03021a050004148a83e0060faff709ca7e9b95522a2e81635fda0a0414f652b0e435d5ea923851508f0adbe92d85de007a0202100f"
84
85 send "show ssl cert ${testdir}/show_ocsp_server.pem.ocsp"
86 expect ~ "Responder Id: C = FR, O = HAProxy Technologies, CN = ocsp.haproxy.com"
87 send "show ssl cert ${testdir}/show_ocsp_server.pem.ocsp"
88 expect ~ "Cert Status: good"
89}
90
91
92# Change the server certificate's OCSP response through "set ssl ocsp-response"
93shell {
William Lallemand2655f2b2021-09-30 17:57:04 +020094 printf "set ssl ocsp-response <<\n$(cat ${testdir}/show_ocsp_server.pem.ocsp.revoked|openssl base64)\n\n" | socat "${tmpdir}/h1/stats" -
Remi Tricot-Le Breton2a77c622021-06-10 13:51:16 +020095}
96
97# Check that the change was taken into account
98haproxy h1 -cli {
99 send "show ssl ocsp-response"
100 expect ~ "Certificate ID key : 303b300906052b0e03021a050004148a83e0060faff709ca7e9b95522a2e81635fda0a0414f652b0e435d5ea923851508f0adbe92d85de007a0202100f"
101
102 send "show ssl ocsp-response 303b300906052b0e03021a050004148a83e0060faff709ca7e9b95522a2e81635fda0a0414f652b0e435d5ea923851508f0adbe92d85de007a0202100f"
103 expect ~ "Responder Id: C = FR, O = HAProxy Technologies, CN = ocsp.haproxy.com"
104 send "show ssl ocsp-response 303b300906052b0e03021a050004148a83e0060faff709ca7e9b95522a2e81635fda0a0414f652b0e435d5ea923851508f0adbe92d85de007a0202100f"
105 expect ~ "Cert Status: revoked"
106
107 send "show ssl cert ${testdir}/show_ocsp_server.pem.ocsp"
108 expect ~ "Cert Status: revoked"
109}
110
111
112# Change the server certificate's OCSP response through a transaction
113shell {
Remi Tricot-Le Breton871df0a2024-02-07 16:38:47 +0100114 printf "set ssl cert ${testdir}/show_ocsp_server.pem <<\n$(cat ${testdir}/show_ocsp_server.pem | sed '/^$/d')\n\n" | socat "${tmpdir}/h1/stats" -
115 printf "set ssl cert ${testdir}/show_ocsp_server.pem.issuer <<\n$(cat ${testdir}/show_ocsp_server.pem.issuer | sed '/^$/d')\n\n" | socat "${tmpdir}/h1/stats" -
William Lallemand2655f2b2021-09-30 17:57:04 +0200116 printf "set ssl cert ${testdir}/show_ocsp_server.pem.ocsp <<\n$(cat ${testdir}/show_ocsp_server.pem.ocsp|openssl base64)\n\n" | socat "${tmpdir}/h1/stats" -
Remi Tricot-Le Breton2a77c622021-06-10 13:51:16 +0200117}
118
119
120# Check that the actual tree entry was not changed and that the uncommitted
121# transaction's OCSP response is the new one
122haproxy h1 -cli {
123 send "show ssl ocsp-response 303b300906052b0e03021a050004148a83e0060faff709ca7e9b95522a2e81635fda0a0414f652b0e435d5ea923851508f0adbe92d85de007a0202100f"
124 expect ~ "Cert Status: revoked"
125 send "show ssl ocsp-response 303b300906052b0e03021a050004148a83e0060faff709ca7e9b95522a2e81635fda0a0414f652b0e435d5ea923851508f0adbe92d85de007a0202100f"
126 expect ~ "This Update: Jun 10 08:57:45 2021 GMT"
127
128 send "show ssl cert *${testdir}/show_ocsp_server.pem.ocsp"
129 expect ~ "Cert Status: good"
130 send "show ssl cert *${testdir}/show_ocsp_server.pem.ocsp"
131 expect ~ "This Update: Jun 10 08:55:04 2021 GMT"
132}
133
134
135# Commit the transaction and check that it was taken into account
136haproxy h1 -cli {
137 send "commit ssl cert ${testdir}/show_ocsp_server.pem"
138 expect ~ "Success!"
139
140 send "show ssl ocsp-response 303b300906052b0e03021a050004148a83e0060faff709ca7e9b95522a2e81635fda0a0414f652b0e435d5ea923851508f0adbe92d85de007a0202100f"
141 expect ~ "Cert Status: good"
142 send "show ssl ocsp-response 303b300906052b0e03021a050004148a83e0060faff709ca7e9b95522a2e81635fda0a0414f652b0e435d5ea923851508f0adbe92d85de007a0202100f"
143 expect ~ "This Update: Jun 10 08:55:04 2021 GMT"
144}