blob: 1dad5cfd8851b15753e0139ed663dbefa4c0f8d6 [file] [log] [blame]
Remi Tricot-Le Breton2f275fb2022-12-20 11:11:16 +01001#REGTEST_TYPE=slow
2
3# broken with BoringSSL.
4
5# This reg-test focuses on the OCSP response auto-update functionality. It does
6# not test the full scope of the feature because most of it is based on
7# expiration times and long delays between updates of valid OCSP responses.
8# Automatic update of valid OCSP responses loaded during init will not be
9# tested because by design, such a response would no be automatically updated
10# until init+1H.
11#
12# This test will then focus on certificates that have a specified OCSP URI but
13# no known OCSP response. For those certificates, OCSP requests are sent as
14# soon as possible by the update task.
15#
16# The ocsp responder used in all the tests will be an openssl using the
17# certificate database in ocsp_update/index.txt. It will listen on port 12346
18# which is not the same as the one specified in the certificates' OCSP URI
19# which point to port 12345. The link from port 12345 to port 12346 will be
20# ensured through HAProxy instances that will enable logs, later used as a
21# synchronization mean.
22#
23# Unfortunately some arbitrary "sleep" calls are still needed to leave some
24# time for the ocsp update task to actually process the ocsp responses and
25# reinsert them into the tree. This explains why the test's mode is set to
26# "slow".
27#
28# If this test does not work anymore:
29# - Check that you have openssl
30
31varnishtest "Test the OCSP auto update feature"
32feature cmd "$HAPROXY_PROGRAM -cc 'version_atleast(2.7-dev0)'"
33feature cmd "$HAPROXY_PROGRAM -cc 'feature(OPENSSL) && !ssllib_name_startswith(BoringSSL) && openssl_version_atleast(1.1.1)'"
34feature cmd "command -v openssl"
35feature ignore_unknown_macro
36
37
38###################
39# #
40# FIRST TEST CASE #
41# #
42###################
43
44# No automatic update should occur in this test case since we load two already
45# valid OCSP responses during init which have a "Next Update" date really far
46# in the future. So they should only be updated after one hour.
47# This test will only be the most basic one where we check that ocsp response
48# loading still works as expected.
49
50haproxy h1 -conf {
51 global
52 tune.ssl.default-dh-param 2048
53 tune.ssl.capture-buffer-size 1
54 stats socket "${tmpdir}/h1/stats" level admin
55 crt-base ${testdir}/ocsp_update
56
57 defaults
58 mode http
59 option httplog
60 log stderr local0 debug err
61 option logasap
62 timeout connect "${HAPROXY_TEST_TIMEOUT-5s}"
63 timeout client "${HAPROXY_TEST_TIMEOUT-5s}"
64 timeout server "${HAPROXY_TEST_TIMEOUT-5s}"
65
66 frontend ssl-fe
67 bind "${tmpdir}/ssl.sock" ssl crt multicert/server_ocsp.pem ca-file ${testdir}/set_cafile_rootCA.crt verify none crt-ignore-err all
68 http-request return status 200
69} -start
70
71
72# We should have two distinct ocsp responses known that were loaded at build time
73haproxy h1 -cli {
74 send "show ssl ocsp-response"
75 expect ~ "Certificate ID key : 303b300906052b0e03021a050004148a83e0060faff709ca7e9b95522a2e81635fda0a0414f652b0e435d5ea923851508f0adbe92d85de007a02021015"
76 send "show ssl ocsp-response"
77 expect ~ "Certificate ID key : 303b300906052b0e03021a050004148a83e0060faff709ca7e9b95522a2e81635fda0a0414f652b0e435d5ea923851508f0adbe92d85de007a02021016"
78
79 send "show ssl ocsp-response 303b300906052b0e03021a050004148a83e0060faff709ca7e9b95522a2e81635fda0a0414f652b0e435d5ea923851508f0adbe92d85de007a02021015"
80 expect ~ "Cert Status: revoked"
81
82 send "show ssl ocsp-response 303b300906052b0e03021a050004148a83e0060faff709ca7e9b95522a2e81635fda0a0414f652b0e435d5ea923851508f0adbe92d85de007a02021016"
83 expect ~ "Cert Status: good"
84}
85
86haproxy h1 -wait
87
88
89
90####################
91# #
92# SECOND TEST CASE #
93# #
94####################
95
96# This test will focus on two separate certificates that have the same OCSP uri
97# (http://ocsp.haproxy.com:12345) but no OCSP response loaded at build time.
98# The update mode is set to 'on' in the two crt-lists used. The two ocsp
99# responses should then be fetched automatically after init. We use an http
100# listener as a rebound on which http log is enabled towards Syslog_http. This
101# ensures that two requests are sent by the ocsp auto update task and it
102# enables to use a barrier to synchronize the ocsp task and the subsequent cli
103# calls. Thanks to the barrier we know that when calling "show ssl
104# ocsp-response" on the cli, the two answers should already have been received
105# and processed.
106
107process p1 "openssl ocsp -index ${testdir}/ocsp_update/index.txt -rsigner ${testdir}/ocsp_update/ocsp.haproxy.com.pem -CA ${testdir}/ocsp_update/ocsp_update_rootca.crt -nrequest 2 -ndays 1 -port 12346 -timeout 5" -start
108
109barrier b1 cond 2 -cyclic
110
111syslog Syslog_http -level info {
112 recv
113 expect ~ "GET /MEMwQTA%2FMD0wOzAJBgUrDgMCGgUABBSKg%2BAGD6%2F3Ccp%2Bm5VSKi6BY1%2FaCgQU9lKw5DXV6pI4UVCPCtvpLYXeAHoCAhAV HTTP/1.1"
114
115 recv
116 expect ~ "GET /MEMwQTA%2FMD0wOzAJBgUrDgMCGgUABBSKg%2BAGD6%2F3Ccp%2Bm5VSKi6BY1%2FaCgQU9lKw5DXV6pI4UVCPCtvpLYXeAHoCAhAW HTTP/1.1"
117
118 barrier b1 sync
119} -start
120
121haproxy h2 -conf {
122 global
123 tune.ssl.default-dh-param 2048
124 tune.ssl.capture-buffer-size 1
125 stats socket "${tmpdir}/h2/stats" level admin
126 crt-base ${testdir}/ocsp_update
127
128 defaults
129 mode http
130 option httplog
131 log stderr local0 debug err
132 timeout connect "${HAPROXY_TEST_TIMEOUT-5s}"
133 timeout client "${HAPROXY_TEST_TIMEOUT-5s}"
134 timeout server "${HAPROXY_TEST_TIMEOUT-5s}"
135
136 frontend ssl-rsa-fe
137 bind "${tmpdir}/ssl2.sock" ssl crt-list ${testdir}/ocsp_update/multicert_rsa.crt-list ca-file ${testdir}/set_cafile_rootCA.crt verify none crt-ignore-err all
138 http-request return status 200
139
140 frontend ssl-ecdsa-fe
141 bind "${tmpdir}/ssl3.sock" ssl crt-list ${testdir}/ocsp_update/multicert_ecdsa.crt-list ca-file ${testdir}/set_cafile_rootCA.crt verify none crt-ignore-err all
142 http-request return status 200
143
144 listen http_rebound_lst
145 mode http
146 option httplog
147 log ${Syslog_http_addr}:${Syslog_http_port} local0
148 bind "127.0.0.1:12345"
149 server s1 "127.0.0.1:12346"
150} -start
151
152barrier b1 sync
153
154shell "sleep 1"
155
156# We should have two distinct ocsp IDs known that were loaded at build time and
157# the responses' contents should have been filled automatically by the ocsp
158# update task after init
159haproxy h2 -cli {
160 send "show ssl ocsp-response"
161 expect ~ "Certificate ID key : 303b300906052b0e03021a050004148a83e0060faff709ca7e9b95522a2e81635fda0a0414f652b0e435d5ea923851508f0adbe92d85de007a02021015"
162 send "show ssl ocsp-response"
163 expect ~ "Certificate ID key : 303b300906052b0e03021a050004148a83e0060faff709ca7e9b95522a2e81635fda0a0414f652b0e435d5ea923851508f0adbe92d85de007a02021016"
164
165 send "show ssl ocsp-response 303b300906052b0e03021a050004148a83e0060faff709ca7e9b95522a2e81635fda0a0414f652b0e435d5ea923851508f0adbe92d85de007a02021015"
166 expect ~ "Cert Status: revoked"
167
168 send "show ssl ocsp-response 303b300906052b0e03021a050004148a83e0060faff709ca7e9b95522a2e81635fda0a0414f652b0e435d5ea923851508f0adbe92d85de007a02021016"
169 expect ~ "Cert Status: revoked"
170}
171
172haproxy h2 -wait
173process p1 -wait -expect-exit 0
174
175
176###################
177# #
178# THIRD TEST CASE #
179# #
180###################
181
182# This test will be roughly the same as the second one but one of the crt-lists
183# will not enable ocsp-update on its certificate. Only one request should then
184# be sent.
185
186process p2 "openssl ocsp -index ${testdir}/ocsp_update/index.txt -rsigner ${testdir}/ocsp_update/ocsp.haproxy.com.pem -CA ${testdir}/ocsp_update/ocsp_update_rootca.crt -nrequest 1 -ndays 1 -port 12346 -timeout 5" -start
187
188barrier b2 cond 2 -cyclic
189
190syslog Syslog_http2 -level info {
191 recv
192 expect ~ "GET /MEMwQTA%2FMD0wOzAJBgUrDgMCGgUABBSKg%2BAGD6%2F3Ccp%2Bm5VSKi6BY1%2FaCgQU9lKw5DXV6pI4UVCPCtvpLYXeAHoCAhAV HTTP/1.1"
193
194 barrier b2 sync
195} -start
196
197haproxy h3 -conf {
198 global
199 tune.ssl.default-dh-param 2048
200 tune.ssl.capture-buffer-size 1
201 stats socket "${tmpdir}/h3/stats" level admin
202 crt-base ${testdir}/ocsp_update
203
204 defaults
205 mode http
206 option httplog
207 log stderr local0 debug err
208 timeout connect "${HAPROXY_TEST_TIMEOUT-5s}"
209 timeout client "${HAPROXY_TEST_TIMEOUT-5s}"
210 timeout server "${HAPROXY_TEST_TIMEOUT-5s}"
211
212 frontend ssl-rsa-fe
213 bind "${tmpdir}/ssl4.sock" ssl crt-list ${testdir}/ocsp_update/multicert_rsa.crt-list ca-file ${testdir}/set_cafile_rootCA.crt verify none crt-ignore-err all
214 http-request return status 200
215
216 frontend ssl-ecdsa-fe
217 bind "${tmpdir}/ssl5.sock" ssl crt-list ${testdir}/ocsp_update/multicert_ecdsa_no_update.crt-list ca-file ${testdir}/set_cafile_rootCA.crt verify none crt-ignore-err all
218 http-request return status 200
219
220 listen http_rebound_lst
221 mode http
222 option httplog
223 log ${Syslog_http2_addr}:${Syslog_http2_port} local0
224 bind "127.0.0.1:12345"
225 server s1 "127.0.0.1:12346"
226} -start
227
228barrier b2 sync
229
230shell "sleep 1"
231
232# We should have a single ocsp ID known that was loaded at build time and the
233# response should be filled
234 haproxy h3 -cli {
235 send "show ssl ocsp-response"
236 expect ~ "Certificate ID key : 303b300906052b0e03021a050004148a83e0060faff709ca7e9b95522a2e81635fda0a0414f652b0e435d5ea923851508f0adbe92d85de007a02021015"
237 send "show ssl ocsp-response"
238 expect !~ "Certificate ID key : 303b300906052b0e03021a050004148a83e0060faff709ca7e9b95522a2e81635fda0a0414f652b0e435d5ea923851508f0adbe92d85de007a02021016"
239
240 send "show ssl ocsp-response 303b300906052b0e03021a050004148a83e0060faff709ca7e9b95522a2e81635fda0a0414f652b0e435d5ea923851508f0adbe92d85de007a02021015"
241 expect ~ "Cert Status: revoked"
242}
243
244haproxy h3 -wait
245process p2 -wait