Debian Codegraph @

tests/ocsp-tests/ocsp-must-staple-connection.sh

raw symbols SCIP
1 #!/bin/shscip-shell filesystem . . `/bin/sh`.
2
3 # Copyright (C) 2016 Red Hat, Inc.
4 #
5 # This file is part of GnuTLS.
6 #
7 # GnuTLS is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License as published by the
9 # Free Software Foundation; either version 3 of the License, or (at
10 # your option) any later version.
11 #
12 # GnuTLS is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 # General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License
18 # along with GnuTLS. If not, see <https://www.gnu.org/licenses/>.
19
20 : ${srcdir=.}
21 : ${CERTTOOL=../src/certtool${EXEEXT}}
22 : ${OCSPTOOL=../src/ocsptool${EXEEXT}}
23 : ${SERV=../src/gnutls-serv${EXEEXT}}
24 : ${CLI=../src/gnutls-cli${EXEEXT}}
25 : ${DIFF=diff}
26
27 export TZ="UTC"
28
29 if ! testscip-shell system . . test. -x "${CERTTOOL}"; then
30 exit 77
31 fi
32
33 if ! testscip-shell system . . test. -x "${OCSPTOOL}"; then
34 exit 77
35 fi
36
37 if ! testscip-shell system . . test. -x "${SERV}"; then
38 exit 77
39 fi
40
41 if ! testscip-shell system . . test. -x "${CLI}"; then
42 exit 77
43 fi
44
45 if ! testscip-shell system . . test. -z "${VALGRIND}"; then
46 VALGRIND="${LIBTOOL:-libtool} --mode=execute ${VALGRIND} --error-exitcode=15"
47 fi
48
49 . "${srcdir}/scripts/common.sh"
50
51 skip_if_no_datefudge
52
53 eval "${GETPORT}"
54 # Port for gnutls-serv
55 TLS_SERVER_PORT=$PORT
56
57 # Port to use for OCSP server, must match the OCSP URI set in the
58 # server_*.pem certificates
59 eval "${GETPORT}"
60 OCSP_PORT=$PORT
61
62 # Maximum timeout for server startup (OCSP and TLS)
63 SERVER_START_TIMEOUT=10
64
65 # Check for OpenSSL
66 : ${OPENSSL=openssl}
67 if ! ("$OPENSSL" version) > /dev/nullscip-shell filesystem . . `/dev/null`. 2>&1; then
68 echoscip-shell system . . echo. "You need openssl to run this test."
69 exit 77
70 fi
71
72 CERTDATE="2016-04-28 00:00:00"
73 TESTDATE="2016-04-29 00:00:00"
74 EXP_OCSP_DATE="2016-03-27 00:00:00"
75
76 OCSP_PID=""
77 TLS_SERVER_PID=""
78
79 testdir=`create_testdir ocsp-must-staple-connection`
80
81 TEMPLATE_FILE="$testdir/ms-out.tmpl.tmp"
82 SERVER_CERT_FILE="$testdir/ms-cert.pem.tmp"
83 SERVER_CERT_NO_EXT_FILE="$testdir/ms-cert-no-ext.pem.tmp"
84 OCSP_RESPONSE_FILE="$testdir/ms-resp.tmp"
85 OCSP_REQ_FILE="$testdir/ms-req.tmp"
86 INDEXFILE="$testdir/ocsp_index.txt"
87 ATTRFILE="${INDEXFILE}.attr"
88 SERVER_CERT_BAD_FILE="$testdir/ms-cert-bad.pem.tmp"
89
90 stop_serversscip-shell shell gnutls28 3.8.13-1 stop_servers(). ()
91 {
92 testscip-shell system . . test. -z "${OCSP_PID}" || killscip-shell system . . kill. "${OCSP_PID}"
93 testscip-shell system . . test. -z "${TLS_SERVER_PID}" || killscip-shell system . . kill. "${TLS_SERVER_PID}"
94 }
95 trap stop_servers 1 15 2
96
97 echoscip-shell system . . echo. "=== Generating good server certificate ==="
98
99 rmscip-shell system . . rm. -f "$TEMPLATE_FILE"
100 cpscip-shell system . . cp. "${srcdir}/ocsp-tests/certs/server_good.template" "$TEMPLATE_FILE"
101 chmodscip-shell system . . chmod. u+w "$TEMPLATE_FILE"
102 echoscip-shell system . . echo. "ocsp_uri=http://localhost:${OCSP_PORT}/ocsp/" >>"$TEMPLATE_FILE"
103
104 # Generate certificates with the random port
105 ${CERTTOOL} \
106 --attime "${CERTDATE}" \
107 --generate-certificate --load-ca-privkey "${srcdir}/ocsp-tests/certs/ca.key" \
108 --load-ca-certificate "${srcdir}/ocsp-tests/certs/ca.pem" \
109 --load-privkey "${srcdir}/ocsp-tests/certs/server_good.key" \
110 --template "${TEMPLATE_FILE}" --outfile "${SERVER_CERT_NO_EXT_FILE}" 2>/dev/nullscip-shell filesystem . . `/dev/null`.
111
112 # Generate certificates with the random port (with mandatory stapling extension)
113 echoscip-shell system . . echo. "tls_feature = 5" >>"$TEMPLATE_FILE"
114
115 ${CERTTOOL} \
116 --attime "${CERTDATE}" \
117 --generate-certificate --load-ca-privkey "${srcdir}/ocsp-tests/certs/ca.key" \
118 --load-ca-certificate "${srcdir}/ocsp-tests/certs/ca.pem" \
119 --load-privkey "${srcdir}/ocsp-tests/certs/server_good.key" \
120 --template "${TEMPLATE_FILE}" --outfile "${SERVER_CERT_FILE}" 2>/dev/nullscip-shell filesystem . . `/dev/null`.
121
122 echoscip-shell system . . echo. "=== Generating bad server certificate ==="
123
124 rmscip-shell system . . rm. -f "$TEMPLATE_FILE"
125 cpscip-shell system . . cp. "${srcdir}/ocsp-tests/certs/server_bad.template" "$TEMPLATE_FILE"
126 chmodscip-shell system . . chmod. u+w "$TEMPLATE_FILE"
127 echoscip-shell system . . echo. "ocsp_uri=http://localhost:${OCSP_PORT}/ocsp/" >>"$TEMPLATE_FILE"
128
129 ${CERTTOOL} \
130 --attime "${CERTDATE}" \
131 --generate-certificate --load-ca-privkey "${srcdir}/ocsp-tests/certs/ca.key" \
132 --load-ca-certificate "${srcdir}/ocsp-tests/certs/ca.pem" \
133 --load-privkey "${srcdir}/ocsp-tests/certs/server_bad.key" \
134 --template "${TEMPLATE_FILE}" --outfile "${SERVER_CERT_BAD_FILE}" 2>/dev/nullscip-shell filesystem . . `/dev/null`.
135
136 echoscip-shell system . . echo. "=== Bringing OCSP server up ==="
137
138 cpscip-shell system . . cp. "${srcdir}/ocsp-tests/certs/ocsp_index.txt" ${INDEXFILE}
139 cpscip-shell system . . cp. "${srcdir}/ocsp-tests/certs/ocsp_index.txt.attr" ${ATTRFILE}
140
141 # Start OpenSSL OCSP server
142 #
143 # WARNING: As of version 1.0.2g, OpenSSL OCSP cannot bind the TCP port
144 # if started repeatedly in a short time, probably a lack of
145 # SO_REUSEADDR usage.
146 PORT=${OCSP_PORT}
147 launch_bare_server \
148 "$FAKETIME" "${TESTDATE}" \
149 "${OPENSSL}" ocsp -index "${INDEXFILE}" -text \
150 -port "${OCSP_PORT}" \
151 -rsigner "${srcdir}/ocsp-tests/certs/ocsp-server.pem" \
152 -rkey "${srcdir}/ocsp-tests/certs/ocsp-server.key" \
153 -CA "${srcdir}/ocsp-tests/certs/ca.pem"
154 OCSP_PID="${!}"
155 wait_server "${OCSP_PID}"
156
157 echoscip-shell system . . echo. "=== Verifying OCSP server is up ==="
158
159 # Port probing (as done in wait_port) makes the OpenSSL OCSP server
160 # crash due to the "invalid request", so try proper requests
161 t=0
162 while testscip-shell system . . test. "${t}" -lt "${SERVER_START_TIMEOUT}"; do
163 # Run a test request to make sure the server works
164 ${VALGRIND} "${OCSPTOOL}" --ask --attime "${TESTDATE}" \
165 --load-cert "${SERVER_CERT_FILE}" \
166 --load-issuer "${srcdir}/ocsp-tests/certs/ca.pem" \
167 --outfile "${OCSP_RESPONSE_FILE}"
168 rc=$?
169 if testscip-shell system . . test. "${rc}" = "0"; then
170 break
171 else
172 t=`exprscip-shell system . . expr. ${t} + 1`
173 sleepscip-shell system . . sleep. 1
174 fi
175 done
176 # Fail if the final OCSP request failed
177 if testscip-shell system . . test. "${rc}" != "0"; then
178 echoscip-shell system . . echo. "OCSP server check failed."
179 exit ${rc}
180 fi
181
182 #echo "placed staple in ${OCSP_RESPONSE_FILE}"
183
184 echoscip-shell system . . echo. "=== Test 1: Server with valid certificate - no staple ==="
185
186 PORT=${TLS_SERVER_PORT}
187 launch_bare_server \
188 "${SERV}" --attime "${TESTDATE}" --echo --disable-client-cert \
189 --x509keyfile="${srcdir}/ocsp-tests/certs/server_good.key" \
190 --x509certfile="${SERVER_CERT_FILE}" \
191 --port="${TLS_SERVER_PORT}"
192 TLS_SERVER_PID="${!}"
193 wait_server $TLS_SERVER_PID
194
195 wait_for_port "${TLS_SERVER_PORT}"
196
197 echoscip-shell system . . echo. "test 123456" | \
198 "${CLI}" --attime "${TESTDATE}" --ocsp --x509cafile="${srcdir}/ocsp-tests/certs/ca.pem" \
199 --port="${TLS_SERVER_PORT}" localhost
200 rc=$?
201
202 if testscip-shell system . . test. "${rc}" = "0"; then
203 echoscip-shell system . . echo. "Connecting to server with valid certificate and no staple succeeded"
204 exit 1
205 fi
206
207 killscip-shell system . . kill. "${TLS_SERVER_PID}"
208 wait "${TLS_SERVER_PID}"
209 unset TLS_SERVER_PID
210
211 echoscip-shell system . . echo. "=== Test 2: Server with valid certificate - valid staple ==="
212
213 eval "${GETPORT}"
214 # Port for gnutls-serv
215 TLS_SERVER_PORT=$PORT
216 PORT=${TLS_SERVER_PORT}
217 launch_bare_server \
218 "${SERV}" --attime "${TESTDATE}" --echo --disable-client-cert \
219 --x509keyfile="${srcdir}/ocsp-tests/certs/server_good.key" \
220 --x509certfile="${SERVER_CERT_FILE}" \
221 --port="${TLS_SERVER_PORT}" \
222 --ocsp-response="${OCSP_RESPONSE_FILE}" --ignore-ocsp-response-errors
223 TLS_SERVER_PID="${!}"
224 wait_server $TLS_SERVER_PID
225
226 wait_for_port "${TLS_SERVER_PORT}"
227
228 echoscip-shell system . . echo. "test 123456" | \
229 "${CLI}" --attime "${TESTDATE}" --ocsp --x509cafile="${srcdir}/ocsp-tests/certs/ca.pem" \
230 --port="${TLS_SERVER_PORT}" localhost
231 rc=$?
232
233 if testscip-shell system . . test. "${rc}" != "0"; then
234 echoscip-shell system . . echo. "Connecting to server with valid certificate and valid staple failed"
235 exit ${rc}
236 fi
237
238 killscip-shell system . . kill. "${TLS_SERVER_PID}"
239 wait "${TLS_SERVER_PID}"
240 unset TLS_SERVER_PID
241
242 echoscip-shell system . . echo. "=== Test 3: Server with valid certificate - invalid staple ==="
243
244 headscip-shell system . . head. -c 64 /dev/urandomscip-shell filesystem . . `/dev/urandom`. >"${OCSP_RESPONSE_FILE}"
245
246 eval "${GETPORT}"
247 # Port for gnutls-serv
248 TLS_SERVER_PORT=$PORT
249 PORT=${TLS_SERVER_PORT}
250 launch_bare_server \
251 "${SERV}" --attime "${TESTDATE}" --echo --disable-client-cert \
252 --x509keyfile="${srcdir}/ocsp-tests/certs/server_good.key" \
253 --x509certfile="${SERVER_CERT_FILE}" \
254 --port="${TLS_SERVER_PORT}" \
255 --ocsp-response="${OCSP_RESPONSE_FILE}" --ignore-ocsp-response-errors
256 TLS_SERVER_PID="${!}"
257 wait_server $TLS_SERVER_PID
258
259 wait_for_port "${TLS_SERVER_PORT}"
260
261 echoscip-shell system . . echo. "test 123456" | \
262 "${CLI}" --attime "${TESTDATE}" --ocsp --x509cafile="${srcdir}/ocsp-tests/certs/ca.pem" \
263 --port="${TLS_SERVER_PORT}" localhost
264 rc=$?
265
266 if testscip-shell system . . test. "${rc}" = "0"; then
267 echoscip-shell system . . echo. "Connecting to server with valid certificate and invalid staple succeeded"
268 exit 1
269 fi
270
271 killscip-shell system . . kill. "${TLS_SERVER_PID}"
272 wait "${TLS_SERVER_PID}"
273 unset TLS_SERVER_PID
274
275 echoscip-shell system . . echo. "=== Test 4: Server with valid certificate - unrelated cert staple ==="
276
277 rmscip-shell system . . rm. -f "${OCSP_RESPONSE_FILE}"
278 cpscip-shell system . . cp. "${srcdir}/ocsp-tests/certs/ocsp-staple-unrelated.der" "${OCSP_RESPONSE_FILE}"
279
280 eval "${GETPORT}"
281 # Port for gnutls-serv
282 TLS_SERVER_PORT=$PORT
283 PORT=${TLS_SERVER_PORT}
284 launch_bare_server \
285 "${SERV}" --attime "${TESTDATE}" --echo --disable-client-cert \
286 --x509keyfile="${srcdir}/ocsp-tests/certs/server_good.key" \
287 --x509certfile="${SERVER_CERT_FILE}" \
288 --port="${TLS_SERVER_PORT}" \
289 --ocsp-response="${OCSP_RESPONSE_FILE}" --ignore-ocsp-response-errors
290 TLS_SERVER_PID="${!}"
291 wait_server $TLS_SERVER_PID
292
293 wait_for_port "${TLS_SERVER_PORT}"
294
295 out=$(
296 echoscip-shell system . . echo. "test 123456" | \
297 "${CLI}" --attime "${TESTDATE}" --ocsp \
298 --x509cafile="${srcdir}/ocsp-tests/certs/ca.pem" \
299 --port="${TLS_SERVER_PORT}" localhost \
300 2>&1
301 )
302 rc=$?
303 printfscip-shell system . . printf. '%s\n' "$out"
304
305 if testscip-shell system . . test. "${rc}" = "0"; then
306 echoscip-shell system . . echo. "Connecting to server with valid certificate and invalid staple succeeded"
307 exit 1
308 fi
309
310 if ! echoscip-shell system . . echo. "${out}" | grepscip-shell system . . grep. "Got OCSP response with an unrelated certificate" > /dev/nullscip-shell filesystem . . `/dev/null`.
311 then
312 echoscip-shell system . . echo. '"Got OCSP response with an unrelated certificate" not found in output'
313 exit 1
314 fi
315
316 killscip-shell system . . kill. "${TLS_SERVER_PID}"
317 wait "${TLS_SERVER_PID}"
318 unset TLS_SERVER_PID
319
320 echoscip-shell system . . echo. "=== Test 4.1: Server with valid certificate - no response staple ==="
321
322 rmscip-shell system . . rm. -f "${OCSP_RESPONSE_FILE}"
323 cpscip-shell system . . cp. "${srcdir}/ocsp-tests/certs/ocsp-staple-empty.der" "${OCSP_RESPONSE_FILE}"
324
325 eval "${GETPORT}"
326 # Port for gnutls-serv
327 TLS_SERVER_PORT=$PORT
328 PORT=${TLS_SERVER_PORT}
329 launch_bare_server \
330 "${SERV}" --attime "${TESTDATE}" --echo --disable-client-cert \
331 --x509keyfile="${srcdir}/ocsp-tests/certs/server_good.key" \
332 --x509certfile="${SERVER_CERT_FILE}" \
333 --port="${TLS_SERVER_PORT}" \
334 --ocsp-response="${OCSP_RESPONSE_FILE}" --ignore-ocsp-response-errors
335 TLS_SERVER_PID="${!}"
336 wait_server $TLS_SERVER_PID
337
338 wait_for_port "${TLS_SERVER_PORT}"
339
340 out=$(
341 echoscip-shell system . . echo. "test 123456" | \
342 "${CLI}" --attime "${TESTDATE}" --ocsp \
343 --x509cafile="${srcdir}/ocsp-tests/certs/ca.pem" \
344 --port="${TLS_SERVER_PORT}" localhost \
345 2>&1
346 )
347 rc=$?
348 printfscip-shell system . . printf. '%s\n' "$out"
349
350 if testscip-shell system . . test. "${rc}" = "0"; then
351 echoscip-shell system . . echo. "Connecting to server with valid certificate and no response staple succeeded"
352 exit 1
353 fi
354
355 if ! echoscip-shell system . . echo. "${out}" | grepscip-shell system . . grep. "Got OCSP response with no certificates" > /dev/nullscip-shell filesystem . . `/dev/null`.
356 then
357 echoscip-shell system . . echo. '"Got OCSP response with no certificates" not found in output'
358 exit 1
359 fi
360
361 killscip-shell system . . kill. "${TLS_SERVER_PID}"
362 wait "${TLS_SERVER_PID}"
363 unset TLS_SERVER_PID
364
365 echoscip-shell system . . echo. "=== Test 5: Server with valid certificate - expired staple ==="
366
367 rmscip-shell system . . rm. -f "${OCSP_RESPONSE_FILE}"
368
369 # Generate an OCSP response which expires in 2 days and use it after
370 # a month. gnutls server doesn't send such a staple to clients.
371 ${VALGRIND} ${OCSPTOOL} --generate-request --load-issuer "${srcdir}/ocsp-tests/certs/ocsp-server.pem" --load-cert "${SERVER_CERT_FILE}" --outfile "${OCSP_REQ_FILE}"
372 "$FAKETIME" "$FAKETIME_F_OPT" "${EXP_OCSP_DATE}" \
373 ${OPENSSL} ocsp -index "${INDEXFILE}" -rsigner "${srcdir}/ocsp-tests/certs/ocsp-server.pem" -rkey "${srcdir}/ocsp-tests/certs/ocsp-server.key" -CA "${srcdir}/ocsp-tests/certs/ca.pem" -reqin "${OCSP_REQ_FILE}" -respout "${OCSP_RESPONSE_FILE}" -ndays 2
374
375 eval "${GETPORT}"
376 # Port for gnutls-serv
377 TLS_SERVER_PORT=$PORT
378 PORT=${TLS_SERVER_PORT}
379
380 : ${TIMEOUT=timeout}
381 if ("$TIMEOUT" --version) >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1; then
382 ${TIMEOUT} 30 "${SERV}" --echo --disable-client-cert \
383 --x509keyfile="${srcdir}/ocsp-tests/certs/server_good.key" \
384 --x509certfile="${SERVER_CERT_FILE}" \
385 --port="${TLS_SERVER_PORT}" \
386 --ocsp-response="${OCSP_RESPONSE_FILE}"
387 if testscip-shell system . . test. $? != 1;then
388 echoscip-shell system . . echo. "Running gnutls-serv with an expired response, succeeds!"
389 exit ${rc}
390 fi
391 fi
392
393 echoscip-shell system . . echo. "=== Test 5.1: Server with valid certificate - expired staple (ignoring errors) ==="
394
395 launch_bare_server \
396 "${SERV}" --attime "${TESTDATE}" --echo --disable-client-cert \
397 --x509keyfile="${srcdir}/ocsp-tests/certs/server_good.key" \
398 --x509certfile="${SERVER_CERT_FILE}" \
399 --port="${TLS_SERVER_PORT}" \
400 --ignore-ocsp-response-errors \
401 --ocsp-response="${OCSP_RESPONSE_FILE}"
402 TLS_SERVER_PID="${!}"
403 wait_server $TLS_SERVER_PID
404
405 wait_for_port "${TLS_SERVER_PORT}"
406
407 echoscip-shell system . . echo. "test 123456" | \
408 "${CLI}" --attime "${TESTDATE}" --ocsp --x509cafile="${srcdir}/ocsp-tests/certs/ca.pem" \
409 --port="${TLS_SERVER_PORT}" localhost
410 rc=$?
411
412 if testscip-shell system . . test. "${rc}" = "0"; then
413 echoscip-shell system . . echo. "Connecting to server with valid certificate and expired staple succeeded"
414 exit 1
415 fi
416
417 killscip-shell system . . kill. "${TLS_SERVER_PID}"
418 wait "${TLS_SERVER_PID}"
419 unset TLS_SERVER_PID
420
421 echoscip-shell system . . echo. "=== Test 6: Server with valid certificate - old staple ==="
422
423 # This case is funny. OCSP doesn't mandate an expiration date for a response so
424 # we are left to decide what to do with responses that don't contain the NextUpdate
425 # field. Here we test whether a month-old response with no clear expiration is rejected.
426
427 rmscip-shell system . . rm. -f "${OCSP_RESPONSE_FILE}"
428
429 ${VALGRIND} ${OCSPTOOL} --generate-request --load-issuer "${srcdir}/ocsp-tests/certs/ocsp-server.pem" --load-cert "${SERVER_CERT_FILE}" --outfile "${OCSP_REQ_FILE}"
430 "$FAKETIME" "$FAKETIME_F_OPT" "${EXP_OCSP_DATE}" \
431 ${OPENSSL} ocsp -index ${INDEXFILE} -rsigner "${srcdir}/ocsp-tests/certs/ocsp-server.pem" -rkey "${srcdir}/ocsp-tests/certs/ocsp-server.key" -CA "${srcdir}/ocsp-tests/certs/ca.pem" -reqin "${OCSP_REQ_FILE}" -respout "${OCSP_RESPONSE_FILE}"
432
433 eval "${GETPORT}"
434 # Port for gnutls-serv
435 TLS_SERVER_PORT=$PORT
436 PORT=${TLS_SERVER_PORT}
437 launch_bare_server \
438 "${SERV}" --attime "${TESTDATE}" --echo --disable-client-cert \
439 --x509keyfile="${srcdir}/ocsp-tests/certs/server_good.key" \
440 --x509certfile="${SERVER_CERT_FILE}" \
441 --port="${TLS_SERVER_PORT}" \
442 --ocsp-response="${OCSP_RESPONSE_FILE}" --ignore-ocsp-response-errors
443 TLS_SERVER_PID="${!}"
444 wait_server $TLS_SERVER_PID
445
446 wait_for_port "${TLS_SERVER_PORT}"
447
448 echoscip-shell system . . echo. "test 123456" | \
449 "${CLI}" --attime "${TESTDATE}" --ocsp --x509cafile="${srcdir}/ocsp-tests/certs/ca.pem" \
450 --port="${TLS_SERVER_PORT}" localhost
451 rc=$?
452
453 if testscip-shell system . . test. "${rc}" = "0"; then
454 echoscip-shell system . . echo. "Connecting to server with valid certificate and old staple succeeded"
455 exit 1
456 fi
457
458 killscip-shell system . . kill. "${TLS_SERVER_PID}"
459 wait "${TLS_SERVER_PID}"
460 unset TLS_SERVER_PID
461
462 if testscip-shell system . . test. "${GNUTLS_FORCE_FIPS_MODE}" != 1; then
463
464 echoscip-shell system . . echo. "=== Test 7: OSCP response error - client doesn't send status_request ==="
465
466 eval "${GETPORT}"
467 # Port for gnutls-serv
468 TLS_SERVER_PORT=$PORT
469 PORT=${TLS_SERVER_PORT}
470 launch_bare_server \
471 "${SERV}" --attime "${TESTDATE}" --echo --disable-client-cert \
472 --x509keyfile="${srcdir}/ocsp-tests/certs/server_good.key" \
473 --x509certfile="${SERVER_CERT_FILE}" \
474 --port="${TLS_SERVER_PORT}" \
475 --ocsp-response="${srcdir}/ocsp-tests/response3.der" --ignore-ocsp-response-errors
476 TLS_SERVER_PID="${!}"
477 wait_server $TLS_SERVER_PID
478
479 wait_for_port "${TLS_SERVER_PORT}"
480
481 ecscip-shell system . . echo.ho "test 123456" | \
482 "${CLI}" --attime "${TESTDATE}" --priority "NORMAL:%NO_EXTENSIONS" --ocsp --x509cafile="${srcdir}/ocsp-tests/certs/ca.pem" \
483 --port="${TLS_SERVER_PORT}" localhost
484 rc=$?
485
486 if testscip-shell system . . test. "${rc}" != "0"; then
487 echoscip-shell system . . echo. "Connecting to server with valid certificate and OCSP error response failed"
488 exit ${rc}
489 fi
490
491 killscip-shell system . . kill. "${TLS_SERVER_PID}"
492 wait "${TLS_SERVER_PID}"
493 unset TLS_SERVER_PID
494
495 fi
496
497 echoscip-shell system . . echo. "=== Test 8: OSCP response error - client sends status_request, no TLS feature extension ==="
498
499 eval "${GETPORT}"
500 # Port for gnutls-serv
501 TLS_SERVER_PORT=$PORT
502 PORT=${TLS_SERVER_PORT}
503 launch_bare_server \
504 "${SERV}" --attime "${TESTDATE}" --echo --disable-client-cert \
505 --x509keyfile="${srcdir}/ocsp-tests/certs/server_good.key" \
506 --x509certfile="${SERVER_CERT_NO_EXT_FILE}" \
507 --port="${TLS_SERVER_PORT}" \
508 --ocsp-response="${srcdir}/ocsp-tests/response3.der" --ignore-ocsp-response-errors
509 TLS_SERVER_PID="${!}"
510 wait_server $TLS_SERVER_PID
511
512 wait_for_port "${TLS_SERVER_PORT}"
513
514 echoscip-shell system . . echo. "test 123456" | \
515 "${CLI}" --attime "${TESTDATE}" --ocsp --x509cafile="${srcdir}/ocsp-tests/certs/ca.pem" \
516 --port="${TLS_SERVER_PORT}" localhost
517 rc=$?
518
519 if testscip-shell system . . test. "${rc}" != "0"; then
520 echoscip-shell system . . echo. "Connecting to server with valid certificate and OCSP error response failed"
521 exit ${rc}
522 fi
523
524 killscip-shell system . . kill. "${TLS_SERVER_PID}"
525 wait "${TLS_SERVER_PID}"
526 unset TLS_SERVER_PID
527
528 echoscip-shell system . . echo. "=== Test 9: OSCP response error - client sends status_request, TLS feature extension present ==="
529
530 eval "${GETPORT}"
531 # Port for gnutls-serv
532 TLS_SERVER_PORT=$PORT
533 PORT=${TLS_SERVER_PORT}
534 launch_bare_server \
535 "${SERV}" --attime "${TESTDATE}" --echo --disable-client-cert \
536 --x509keyfile="${srcdir}/ocsp-tests/certs/server_good.key" \
537 --x509certfile="${SERVER_CERT_FILE}" \
538 --port="${TLS_SERVER_PORT}" \
539 --ocsp-response="${srcdir}/ocsp-tests/response3.der" --ignore-ocsp-response-errors
540 TLS_SERVER_PID="${!}"
541 wait_server $TLS_SERVER_PID
542
543 wait_for_port "${TLS_SERVER_PORT}"
544
545 echoscip-shell system . . echo. "test 123456" | \
546 "${CLI}" --attime "${TESTDATE}" --ocsp --x509cafile="${srcdir}/ocsp-tests/certs/ca.pem" \
547 --port="${TLS_SERVER_PORT}" localhost
548 rc=$?
549
550 if testscip-shell system . . test. "${rc}" = "0"; then
551 echoscip-shell system . . echo. "Connecting to server with valid certificate and OCSP error response unexpectedly succeeded"
552 exit 1
553 fi
554
555 killscip-shell system . . kill. "${TLS_SERVER_PID}"
556 wait "${TLS_SERVER_PID}"
557 unset TLS_SERVER_PID
558
559 echoscip-shell system . . echo. "=== Test 10: Server with revoked certificate - CVE-2026-3832 ==="
560
561 # The revocation status was always mistakenly checked for the first cert.
562 # Check a pair of responses: (irrelevant good unrevoked, relevant bad revoked).
563
564 rmscip-shell system . . rm. -f "${OCSP_RESPONSE_FILE}"
565
566 "$FAKETIME" "${TESTDATE}" \
567 ${OPENSSL} ocsp -index "${INDEXFILE}" \
568 -issuer "${srcdir}/ocsp-tests/certs/ca.pem" \
569 -CA "${srcdir}/ocsp-tests/certs/ca.pem" \
570 -rsigner "${srcdir}/ocsp-tests/certs/ocsp-server.pem" \
571 -rkey "${srcdir}/ocsp-tests/certs/ocsp-server.key" \
572 -cert "${SERVER_CERT_FILE}" \
573 -cert "${SERVER_CERT_BAD_FILE}" \
574 -respout "${OCSP_RESPONSE_FILE}"
575
576 eval "${GETPORT}"
577 # Port for gnutls-serv
578 TLS_SERVER_PORT=$PORT
579 PORT=${TLS_SERVER_PORT}
580 launch_bare_server \
581 "${SERV}" --attime "${TESTDATE}" --echo --disable-client-cert \
582 --x509keyfile="${srcdir}/ocsp-tests/certs/server_bad.key" \
583 --x509certfile="${SERVER_CERT_BAD_FILE}" \
584 --port="${TLS_SERVER_PORT}" \
585 --ocsp-response="${OCSP_RESPONSE_FILE}" --ignore-ocsp-response-errors
586 TLS_SERVER_PID="${!}"
587 wait_server $TLS_SERVER_PID
588
589 wait_for_port "${TLS_SERVER_PORT}"
590
591 out=$(
592 echoscip-shell system . . echo. "test 123456" | \
593 "${CLI}" -d1 --attime "${TESTDATE}" --ocsp \
594 --x509cafile "${srcdir}/ocsp-tests/certs/ca.pem" \
595 --port "${TLS_SERVER_PORT}" localhost \
596 2>&1
597 rc=$?
598 )
599 printfscip-shell system . . printf. '%s\n' "$out"
600
601 if testscip-shell system . . test. "${rc}" = "0"; then
602 echoscip-shell system . . echo. 'ERROR: client accepted a revoked leaf (CVE-2026-3832)'
603 exit 1
604 fi
605 if ! echoscip-shell system . . echo. "${out}" | grepscip-shell system . . grep. "The certificate was revoked via OCSP" >/dev/nullscip-shell filesystem . . `/dev/null`.
606 then
607 echoscip-shell system . . echo. '"The certificate was revoked via OCSP" not found in output'
608 exit 1
609 fi
610
611 killscip-shell system . . kill. "${TLS_SERVER_PID}"
612 wait "${TLS_SERVER_PID}"
613 unset TLS_SERVER_PID
614
615 killscip-shell system . . kill. ${OCSP_PID}
616 wait ${OCSP_PID}
617 unset OCSP_PID
618
619 rmscip-shell system . . rm. -rf "$testdir"
620
621 exit 0