blob: a1d9a3c8d06f19ec12d2d6721d3013b88f06f0ce [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#
Remi Tricot-Le Breton522841c2023-01-12 09:49:12 +010028# The fourth test case focuses on the "update ssl ocsp-response" CLI command
29# and tests two certificates that have a known OCSP response loaded during init
30# but no OCSP auto update. The only difference between the two certificates is
31# that one has a separate .issuer file while the other one has the issuer
32# certificate directly in the main .pem file.
33#
Remi Tricot-Le Breton2f275fb2022-12-20 11:11:16 +010034# If this test does not work anymore:
Remi Tricot-Le Breton522841c2023-01-12 09:49:12 +010035# - Check that you have openssl and socat
Remi Tricot-Le Breton2f275fb2022-12-20 11:11:16 +010036
37varnishtest "Test the OCSP auto update feature"
38feature cmd "$HAPROXY_PROGRAM -cc 'version_atleast(2.7-dev0)'"
39feature cmd "$HAPROXY_PROGRAM -cc 'feature(OPENSSL) && !ssllib_name_startswith(BoringSSL) && openssl_version_atleast(1.1.1)'"
Remi Tricot-Le Breton522841c2023-01-12 09:49:12 +010040feature cmd "command -v openssl && command -v socat"
Remi Tricot-Le Breton2f275fb2022-12-20 11:11:16 +010041feature ignore_unknown_macro
42
43
44###################
45# #
46# FIRST TEST CASE #
47# #
48###################
49
50# No automatic update should occur in this test case since we load two already
51# valid OCSP responses during init which have a "Next Update" date really far
52# in the future. So they should only be updated after one hour.
53# This test will only be the most basic one where we check that ocsp response
54# loading still works as expected.
55
56haproxy h1 -conf {
57 global
58 tune.ssl.default-dh-param 2048
59 tune.ssl.capture-buffer-size 1
60 stats socket "${tmpdir}/h1/stats" level admin
61 crt-base ${testdir}/ocsp_update
62
63 defaults
64 mode http
65 option httplog
66 log stderr local0 debug err
67 option logasap
68 timeout connect "${HAPROXY_TEST_TIMEOUT-5s}"
69 timeout client "${HAPROXY_TEST_TIMEOUT-5s}"
70 timeout server "${HAPROXY_TEST_TIMEOUT-5s}"
71
72 frontend ssl-fe
73 bind "${tmpdir}/ssl.sock" ssl crt multicert/server_ocsp.pem ca-file ${testdir}/set_cafile_rootCA.crt verify none crt-ignore-err all
74 http-request return status 200
75} -start
76
77
78# We should have two distinct ocsp responses known that were loaded at build time
79haproxy h1 -cli {
80 send "show ssl ocsp-response"
81 expect ~ "Certificate ID key : 303b300906052b0e03021a050004148a83e0060faff709ca7e9b95522a2e81635fda0a0414f652b0e435d5ea923851508f0adbe92d85de007a02021015"
82 send "show ssl ocsp-response"
83 expect ~ "Certificate ID key : 303b300906052b0e03021a050004148a83e0060faff709ca7e9b95522a2e81635fda0a0414f652b0e435d5ea923851508f0adbe92d85de007a02021016"
84
85 send "show ssl ocsp-response 303b300906052b0e03021a050004148a83e0060faff709ca7e9b95522a2e81635fda0a0414f652b0e435d5ea923851508f0adbe92d85de007a02021015"
86 expect ~ "Cert Status: revoked"
87
88 send "show ssl ocsp-response 303b300906052b0e03021a050004148a83e0060faff709ca7e9b95522a2e81635fda0a0414f652b0e435d5ea923851508f0adbe92d85de007a02021016"
89 expect ~ "Cert Status: good"
90}
91
92haproxy h1 -wait
93
94
95
96####################
97# #
98# SECOND TEST CASE #
99# #
100####################
101
102# This test will focus on two separate certificates that have the same OCSP uri
103# (http://ocsp.haproxy.com:12345) but no OCSP response loaded at build time.
104# The update mode is set to 'on' in the two crt-lists used. The two ocsp
105# responses should then be fetched automatically after init. We use an http
106# listener as a rebound on which http log is enabled towards Syslog_http. This
107# ensures that two requests are sent by the ocsp auto update task and it
108# enables to use a barrier to synchronize the ocsp task and the subsequent cli
109# calls. Thanks to the barrier we know that when calling "show ssl
110# ocsp-response" on the cli, the two answers should already have been received
111# and processed.
112
113process 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
114
115barrier b1 cond 2 -cyclic
116
117syslog Syslog_http -level info {
118 recv
119 expect ~ "GET /MEMwQTA%2FMD0wOzAJBgUrDgMCGgUABBSKg%2BAGD6%2F3Ccp%2Bm5VSKi6BY1%2FaCgQU9lKw5DXV6pI4UVCPCtvpLYXeAHoCAhAV HTTP/1.1"
120
121 recv
122 expect ~ "GET /MEMwQTA%2FMD0wOzAJBgUrDgMCGgUABBSKg%2BAGD6%2F3Ccp%2Bm5VSKi6BY1%2FaCgQU9lKw5DXV6pI4UVCPCtvpLYXeAHoCAhAW HTTP/1.1"
123
124 barrier b1 sync
125} -start
126
127haproxy h2 -conf {
128 global
129 tune.ssl.default-dh-param 2048
130 tune.ssl.capture-buffer-size 1
131 stats socket "${tmpdir}/h2/stats" level admin
132 crt-base ${testdir}/ocsp_update
133
134 defaults
135 mode http
136 option httplog
137 log stderr local0 debug err
138 timeout connect "${HAPROXY_TEST_TIMEOUT-5s}"
139 timeout client "${HAPROXY_TEST_TIMEOUT-5s}"
140 timeout server "${HAPROXY_TEST_TIMEOUT-5s}"
141
142 frontend ssl-rsa-fe
143 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
144 http-request return status 200
145
146 frontend ssl-ecdsa-fe
147 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
148 http-request return status 200
149
150 listen http_rebound_lst
151 mode http
152 option httplog
153 log ${Syslog_http_addr}:${Syslog_http_port} local0
154 bind "127.0.0.1:12345"
155 server s1 "127.0.0.1:12346"
156} -start
157
158barrier b1 sync
159
160shell "sleep 1"
161
162# We should have two distinct ocsp IDs known that were loaded at build time and
163# the responses' contents should have been filled automatically by the ocsp
164# update task after init
165haproxy h2 -cli {
166 send "show ssl ocsp-response"
167 expect ~ "Certificate ID key : 303b300906052b0e03021a050004148a83e0060faff709ca7e9b95522a2e81635fda0a0414f652b0e435d5ea923851508f0adbe92d85de007a02021015"
168 send "show ssl ocsp-response"
169 expect ~ "Certificate ID key : 303b300906052b0e03021a050004148a83e0060faff709ca7e9b95522a2e81635fda0a0414f652b0e435d5ea923851508f0adbe92d85de007a02021016"
170
171 send "show ssl ocsp-response 303b300906052b0e03021a050004148a83e0060faff709ca7e9b95522a2e81635fda0a0414f652b0e435d5ea923851508f0adbe92d85de007a02021015"
172 expect ~ "Cert Status: revoked"
173
174 send "show ssl ocsp-response 303b300906052b0e03021a050004148a83e0060faff709ca7e9b95522a2e81635fda0a0414f652b0e435d5ea923851508f0adbe92d85de007a02021016"
175 expect ~ "Cert Status: revoked"
176}
177
178haproxy h2 -wait
179process p1 -wait -expect-exit 0
180
181
182###################
183# #
184# THIRD TEST CASE #
185# #
186###################
187
188# This test will be roughly the same as the second one but one of the crt-lists
189# will not enable ocsp-update on its certificate. Only one request should then
190# be sent.
191
192process 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
193
194barrier b2 cond 2 -cyclic
195
196syslog Syslog_http2 -level info {
197 recv
198 expect ~ "GET /MEMwQTA%2FMD0wOzAJBgUrDgMCGgUABBSKg%2BAGD6%2F3Ccp%2Bm5VSKi6BY1%2FaCgQU9lKw5DXV6pI4UVCPCtvpLYXeAHoCAhAV HTTP/1.1"
199
200 barrier b2 sync
201} -start
202
203haproxy h3 -conf {
204 global
205 tune.ssl.default-dh-param 2048
206 tune.ssl.capture-buffer-size 1
207 stats socket "${tmpdir}/h3/stats" level admin
208 crt-base ${testdir}/ocsp_update
209
210 defaults
211 mode http
212 option httplog
213 log stderr local0 debug err
214 timeout connect "${HAPROXY_TEST_TIMEOUT-5s}"
215 timeout client "${HAPROXY_TEST_TIMEOUT-5s}"
216 timeout server "${HAPROXY_TEST_TIMEOUT-5s}"
217
218 frontend ssl-rsa-fe
219 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
220 http-request return status 200
221
222 frontend ssl-ecdsa-fe
223 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
224 http-request return status 200
225
226 listen http_rebound_lst
227 mode http
228 option httplog
229 log ${Syslog_http2_addr}:${Syslog_http2_port} local0
230 bind "127.0.0.1:12345"
231 server s1 "127.0.0.1:12346"
232} -start
233
234barrier b2 sync
235
236shell "sleep 1"
237
238# We should have a single ocsp ID known that was loaded at build time and the
239# response should be filled
Remi Tricot-Le Breton522841c2023-01-12 09:49:12 +0100240haproxy h3 -cli {
Remi Tricot-Le Breton2f275fb2022-12-20 11:11:16 +0100241 send "show ssl ocsp-response"
242 expect ~ "Certificate ID key : 303b300906052b0e03021a050004148a83e0060faff709ca7e9b95522a2e81635fda0a0414f652b0e435d5ea923851508f0adbe92d85de007a02021015"
243 send "show ssl ocsp-response"
244 expect !~ "Certificate ID key : 303b300906052b0e03021a050004148a83e0060faff709ca7e9b95522a2e81635fda0a0414f652b0e435d5ea923851508f0adbe92d85de007a02021016"
245
246 send "show ssl ocsp-response 303b300906052b0e03021a050004148a83e0060faff709ca7e9b95522a2e81635fda0a0414f652b0e435d5ea923851508f0adbe92d85de007a02021015"
247 expect ~ "Cert Status: revoked"
248}
249
250haproxy h3 -wait
251process p2 -wait
Remi Tricot-Le Breton522841c2023-01-12 09:49:12 +0100252
253
254
255####################
256# #
257# FOURTH TEST CASE #
258# (CLI COMMAND) #
259# #
260####################
261
262process p3 "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
263
264haproxy h4 -conf {
265 global
266 tune.ssl.default-dh-param 2048
267 tune.ssl.capture-buffer-size 1
268 stats socket "${tmpdir}/h4/stats" level admin
269 crt-base ${testdir}/ocsp_update
270
271 defaults
272 mode http
273 option httplog
274 log stderr local0 debug err
275 timeout connect "${HAPROXY_TEST_TIMEOUT-5s}"
276 timeout client "${HAPROXY_TEST_TIMEOUT-5s}"
277 timeout server "${HAPROXY_TEST_TIMEOUT-5s}"
278
279 frontend ssl-rsa-ocsp
280 bind "${tmpdir}/ssl5.sock" ssl crt ${testdir}/ocsp_update/multicert/server_ocsp.pem.rsa ca-file ${testdir}/set_cafile_rootCA.crt verify none crt-ignore-err all
281 http-request return status 200
282
283 frontend ssl-ecdsa-ocsp
284 bind "${tmpdir}/ssl6.sock" ssl crt ${testdir}/ocsp_update/multicert/server_ocsp_ecdsa.pem ca-file ${testdir}/set_cafile_rootCA.crt verify none crt-ignore-err all
285 http-request return status 200
286
287 listen http_rebound_lst
288 mode http
289 option httplog
290 bind "127.0.0.1:12345"
Remi Tricot-Le Bretona6c0a592023-03-13 15:56:32 +0100291 http-response set-var(proc.processed) int(1)
Remi Tricot-Le Breton522841c2023-01-12 09:49:12 +0100292 server s1 "127.0.0.1:12346"
293} -start
294
295# We need to "enable" the cli with a first cli call before using it only through socats
296haproxy h4 -cli {
297 send "show ssl ocsp-response"
298 expect ~ "Certificate ID key : 303b300906052b0e03021a050004148a83e0060faff709ca7e9b95522a2e81635fda0a0414f652b0e435d5ea923851508f0adbe92d85de007a02021016"
299}
300
301# We should have two OCSP responses loaded during init
302shell {
303 responses=$(echo "show ssl ocsp-response" | socat "${tmpdir}/h4/stats" -)
304
305 [ $(echo "$responses" | grep -c "^Certificate ID key") -eq 2 ] && \
306 echo "$responses" | grep "Serial Number: 1016" && \
307 echo "$responses" | grep "Serial Number: 1015"
308}
309
310shell {
311 echo "show ssl ocsp-response 303b300906052b0e03021a050004148a83e0060faff709ca7e9b95522a2e81635fda0a0414f652b0e435d5ea923851508f0adbe92d85de007a02021015" | socat "${tmpdir}/h4/stats" - | grep "Cert Status: revoked"
312}
313
314shell {
315 echo "show ssl ocsp-response 303b300906052b0e03021a050004148a83e0060faff709ca7e9b95522a2e81635fda0a0414f652b0e435d5ea923851508f0adbe92d85de007a02021016" | socat "${tmpdir}/h4/stats" - | grep "Cert Status: good"
316}
317
318# Update the first ocsp response (ckch_data has a non-NULL ocsp_issuer pointer)
319shell {
320 # Store the current "Produced At" in order to ensure that after the update
321 # the OCSP response actually changed
322 produced_at=$(echo "show ssl ocsp-response 303b300906052b0e03021a050004148a83e0060faff709ca7e9b95522a2e81635fda0a0414f652b0e435d5ea923851508f0adbe92d85de007a02021015" | socat "${tmpdir}/h4/stats" - | grep "Produced At")
Remi Tricot-Le Breton522841c2023-01-12 09:49:12 +0100323
Remi Tricot-Le Bretona6c0a592023-03-13 15:56:32 +0100324 echo "update ssl ocsp-response ${testdir}/ocsp_update/multicert/server_ocsp.pem.rsa" | socat "${tmpdir}/h4/stats" -
325 while ! echo "get var proc.processed" | socat "${tmpdir}/h4/stats" - | grep 'proc.processed: type=sint value=<1>'
326 do
327 echo "get var proc.processed" | socat "${tmpdir}/h4/stats" - >> /tmp/toto
328 sleep 0.5
329 done
330
331 echo "experimental-mode on;set var proc.processed int(0)" | socat "${tmpdir}/h4/stats" -
332
333 ocsp_response=$(echo "show ssl ocsp-response 303b300906052b0e03021a050004148a83e0060faff709ca7e9b95522a2e81635fda0a0414f652b0e435d5ea923851508f0adbe92d85de007a02021015" | socat "${tmpdir}/h4/stats" -)
Remi Tricot-Le Breton522841c2023-01-12 09:49:12 +0100334 new_produced_at=$(echo "$ocsp_response" | grep "Produced At")
335
336 echo "$ocsp_response" | grep -q "Serial Number: 1015" && \
337 echo "$ocsp_response" | grep -q "Cert Status: revoked" && \
338 [ "$new_produced_at" != "$produced_at" ]
339}
340
341# Update the second ocsp response (ckch_data has a NULL ocsp_issuer pointer)
342shell {
343 # Store the current "Produced At" in order to ensure that after the update
344 # the OCSP response actually changed
345 produced_at=$(echo "show ssl ocsp-response 303b300906052b0e03021a050004148a83e0060faff709ca7e9b95522a2e81635fda0a0414f652b0e435d5ea923851508f0adbe92d85de007a02021016" | socat "${tmpdir}/h4/stats" - | grep "Produced At")
Remi Tricot-Le Breton522841c2023-01-12 09:49:12 +0100346
Remi Tricot-Le Bretona6c0a592023-03-13 15:56:32 +0100347 echo "update ssl ocsp-response ${testdir}/ocsp_update/multicert/server_ocsp_ecdsa.pem" | socat "${tmpdir}/h4/stats" -
348 while ! echo "get var proc.processed" | socat "${tmpdir}/h4/stats" - | grep 'proc.processed: type=sint value=<1>'
349 do
350 echo "get var proc.processed" | socat "${tmpdir}/h4/stats" - >> /tmp/toto
351 sleep 0.5
352 done
353
354 echo "experimental-mode on;set var proc.processed int(0)" | socat "${tmpdir}/h4/stats" -
355
356 ocsp_response=$(echo "show ssl ocsp-response 303b300906052b0e03021a050004148a83e0060faff709ca7e9b95522a2e81635fda0a0414f652b0e435d5ea923851508f0adbe92d85de007a02021016" | socat "${tmpdir}/h4/stats" -)
Remi Tricot-Le Breton522841c2023-01-12 09:49:12 +0100357 new_produced_at=$(echo "$ocsp_response" | grep "Produced At")
358
359 echo "$ocsp_response" | grep -q "Serial Number: 1016" && \
360 echo "$ocsp_response" | grep -q "Cert Status: revoked" && \
361 [ "$new_produced_at" != "$produced_at" ]
362}
363
364haproxy h4 -wait
365process p3 -wait
Remi Tricot-Le Breton5ab54c62023-03-02 15:49:51 +0100366
367
368####################
369# #
370# FIFTH TEST CASE #
371# (CLI COMMAND) #
372# #
373####################
374
375# Test the "show ssl ocsp-updates" command as well as the new 'base64' parameter
376# to the "show ssl ocsp-response" command.
377
378
379process p5 "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
380
381barrier b5 cond 2 -cyclic
382
383syslog Syslog_http5 -level info {
384 recv
385 expect ~ "GET /MEMwQTA%2FMD0wOzAJBgUrDgMCGgUABBSKg%2BAGD6%2F3Ccp%2Bm5VSKi6BY1%2FaCgQU9lKw5DXV6pI4UVCPCtvpLYXeAHoCAhAV HTTP/1.1"
386
387 recv
388 expect ~ "GET /MEMwQTA%2FMD0wOzAJBgUrDgMCGgUABBSKg%2BAGD6%2F3Ccp%2Bm5VSKi6BY1%2FaCgQU9lKw5DXV6pI4UVCPCtvpLYXeAHoCAhAW HTTP/1.1"
389
390 barrier b5 sync
391} -start
392
393haproxy h5 -conf {
394 global
395 tune.ssl.default-dh-param 2048
396 tune.ssl.capture-buffer-size 1
397 stats socket "${tmpdir}/h5/stats" level admin
398 crt-base ${testdir}/ocsp_update
399
400 defaults
401 mode http
402 option httplog
403 log stderr local0 debug err
404 timeout connect "${HAPROXY_TEST_TIMEOUT-5s}"
405 timeout client "${HAPROXY_TEST_TIMEOUT-5s}"
406 timeout server "${HAPROXY_TEST_TIMEOUT-5s}"
407
408 frontend ssl-rsa-fe
409 bind "${tmpdir}/ssl7.sock" ssl crt-list ${testdir}/ocsp_update/multicert_rsa.crt-list ca-file ${testdir}/set_cafile_rootCA.crt verify none crt-ignore-err all
410 http-request return status 200
411
412 frontend ssl-ecdsa-fe
413 bind "${tmpdir}/ssl8.sock" ssl crt-list ${testdir}/ocsp_update/multicert_ecdsa.crt-list ca-file ${testdir}/set_cafile_rootCA.crt verify none crt-ignore-err all
414 http-request return status 200
415
416 listen http_rebound_lst
417 mode http
418 option httplog
419 log ${Syslog_http5_addr}:${Syslog_http5_port} local0
420 bind "127.0.0.1:12345"
421 server s1 "127.0.0.1:12346"
422} -start
423
424barrier b5 sync
425
426shell "sleep 1"
427
428# Use "show ssl ocsp-updates" CLI command
429# We should have one line per OCSP response and each one of them should have been successfully updated once
430# The command's output follows this format:
431# OCSP Certid | Next Update | Last Update | Successes | Failures | Last Update Status | Last Update Status (str)
432haproxy h5 -cli {
433 send "show ssl ocsp-updates"
434 expect ~ "303b300906052b0e03021a050004148a83e0060faff709ca7e9b95522a2e81635fda0a0414f652b0e435d5ea923851508f0adbe92d85de007a02021015 .*| 1 | 0 | 1 | Update successful"
435
436 send "show ssl ocsp-updates"
437 expect ~ "303b300906052b0e03021a050004148a83e0060faff709ca7e9b95522a2e81635fda0a0414f652b0e435d5ea923851508f0adbe92d85de007a02021016 .*| 1 | 0 | 1 | Update successful"
438}
439
440# Use "show ssl ocsp-response" command to dump an OCSP response in base64
441shell {
442 ocsp_resp_file="${tmpdir}.ocsp_resp.der"
443
444 echo "show ssl ocsp-response base64 303b300906052b0e03021a050004148a83e0060faff709ca7e9b95522a2e81635fda0a0414f652b0e435d5ea923851508f0adbe92d85de007a02021015" | socat "${tmpdir}/h5/stats" - | base64 -d > $ocsp_resp_file
445
446 if [ $? -eq 0 ]
447 then
448 ocsp_resp_txt="$(openssl ocsp -respin $ocsp_resp_file -noverify -text)"
449 echo "$ocsp_resp_txt" | grep "Issuer Name Hash: 8A83E0060FAFF709CA7E9B95522A2E81635FDA0A" && \
450 echo "$ocsp_resp_txt" | grep "Issuer Key Hash: F652B0E435D5EA923851508F0ADBE92D85DE007A" && \
451 echo "$ocsp_resp_txt" | grep "Serial Number: 1015" && \
452 echo "$ocsp_resp_txt" | grep "Cert Status: revoked"
453 else
454 return 1
455 fi
456}
457
458haproxy h5 -wait
459process p5 -wait
Remi Tricot-Le Breton86d1e0b2023-03-02 15:49:53 +0100460
461
462####################
463# #
464# SIXTH TEST CASE #
465# #
466####################
467
468# Check that a new certificate added via the CLI to a crt-list with
469# the 'ocsp-update on' option will be taken into account by the OCSP
470# auto update task
471#
472process p6 "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
473
474barrier b6 cond 2 -cyclic
475
476syslog Syslog_http6 -level info {
477 recv
478 expect ~ "GET /MEMwQTA%2FMD0wOzAJBgUrDgMCGgUABBSKg%2BAGD6%2F3Ccp%2Bm5VSKi6BY1%2FaCgQU9lKw5DXV6pI4UVCPCtvpLYXeAHoCAhAV HTTP/1.1"
479
480 barrier b6 sync
481} -start
482
483haproxy h6 -conf {
484 global
485 tune.ssl.default-dh-param 2048
486 tune.ssl.capture-buffer-size 1
487 stats socket "${tmpdir}/h6/stats" level admin
488 crt-base ${testdir}
489
490 defaults
491 mode http
492 option httplog
493 log stderr local0 debug err
494 option logasap
495 timeout connect "${HAPROXY_TEST_TIMEOUT-5s}"
496 timeout client "${HAPROXY_TEST_TIMEOUT-5s}"
497 timeout server "${HAPROXY_TEST_TIMEOUT-5s}"
498
499 frontend ssl-fe
Remi Tricot-Le Bretona6c0a592023-03-13 15:56:32 +0100500 bind "${tmpdir}/ssl9.sock" ssl crt-list ${testdir}/simple.crt-list ca-file ${testdir}/set_cafile_rootCA.crt verify none crt-ignore-err all
Remi Tricot-Le Breton86d1e0b2023-03-02 15:49:53 +0100501 http-request return status 200
502
503 listen http_rebound_lst
504 mode http
505 option httplog
506 log ${Syslog_http6_addr}:${Syslog_http6_port} local0
507 bind "127.0.0.1:12345"
508 server s1 "127.0.0.1:12346"
509} -start
510
511# We need to "enable" the cli with a first cli call before using it only through socats
512haproxy h6 -cli {
513 send "show ssl cert"
514 expect ~ ""
515}
516
517# Create a new certificate that has an OCSP uri and add it to the
518# existing CLI with the 'ocsp-update on' command.
519shell {
520 echo "new ssl cert ${testdir}/ocsp_update/multicert/server_ocsp.pem.rsa" | socat "${tmpdir}/h6/stats" -
521 printf "set ssl cert ${testdir}/ocsp_update/multicert/server_ocsp.pem.rsa <<\n$(cat ${testdir}/ocsp_update/multicert/server_ocsp.pem.rsa)\n\n" | socat "${tmpdir}/h6/stats" -
522 printf "set ssl cert ${testdir}/ocsp_update/multicert/server_ocsp.pem.rsa.issuer <<\n$(cat ${testdir}/ocsp_update/multicert/server_ocsp.pem.rsa.issuer)\n\n" | socat "${tmpdir}/h6/stats" -
523 echo "commit ssl cert ${testdir}/ocsp_update/multicert/server_ocsp.pem.rsa" | socat "${tmpdir}/h6/stats" -
524
525 printf "add ssl crt-list ${testdir}/simple.crt-list <<\n${testdir}/ocsp_update/multicert/server_ocsp.pem.rsa [ocsp-update on] foo.com\n\n" | socat "${tmpdir}/h6/stats" -
526}
527
528barrier b6 sync
529
530shell "sleep 1"
531
532haproxy h6 -cli {
533 send "show ssl ocsp-updates"
534 expect ~ "303b300906052b0e03021a050004148a83e0060faff709ca7e9b95522a2e81635fda0a0414f652b0e435d5ea923851508f0adbe92d85de007a02021016 .*| 1 | 0 | 1 | Update successful"
535}