aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheo Buehler <tb@openbsd.org>2026-07-31 09:29:16 +0200
committerTheo Buehler <tb@openbsd.org>2026-07-31 09:29:16 +0200
commit3c46654fb6b3082e2835d6250320fa9cdd50a077 (patch)
tree09165d046f459b8ff77475b88332a1edfd2359da
parent0ab79b7c8111fce123821c752655c7e6e55110f8 (diff)
parenta10cbdaf4fb6d11f741464ef162c1ffdeeb926b2 (diff)
downloadportable-3c46654fb6b3082e2835d6250320fa9cdd50a077.tar.gz
portable-3c46654fb6b3082e2835d6250320fa9cdd50a077.tar.bz2
portable-3c46654fb6b3082e2835d6250320fa9cdd50a077.zip
Land #1343 - hook up x509 callback tests
-rw-r--r--tests/CMakeLists.txt28
-rw-r--r--tests/Makefile.am20
-rwxr-xr-xtests/x509_callbacks.sh94
-rwxr-xr-xupdate.sh1
4 files changed, 135 insertions, 8 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 92588cc..ac9c5ba 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -342,8 +342,30 @@ add_executable(bytestringtest bytestringtest.c)
342target_link_libraries(bytestringtest ${OPENSSL_TEST_LIBS}) 342target_link_libraries(bytestringtest ${OPENSSL_TEST_LIBS})
343add_platform_test(bytestringtest bytestringtest) 343add_platform_test(bytestringtest bytestringtest)
344 344
345# callback 345# x509_callbacks
346# callbackfailures 346add_executable(callback callback.c)
347target_link_libraries(callback ${OPENSSL_TEST_LIBS})
348add_executable(callbackfailures callbackfailures.c)
349target_link_libraries(callbackfailures ${OPENSSL_TEST_LIBS})
350add_executable(expirecallback expirecallback.c)
351target_link_libraries(expirecallback ${OPENSSL_TEST_LIBS})
352add_dependencies(callback openssl)
353if(NOT WIN32 AND NOT EMSCRIPTEN AND PERL_EXECUTABLE)
354 add_test(NAME x509_callbacks COMMAND
355 ${CMAKE_CURRENT_SOURCE_DIR}/x509_callbacks.sh
356 $<TARGET_FILE:callback>
357 $<TARGET_FILE:callbackfailures>
358 $<TARGET_FILE:expirecallback>
359 $<TARGET_FILE:openssl>)
360 set_tests_properties(x509_callbacks PROPERTIES
361 ENVIRONMENT "srcdir=${TEST_SOURCE_DIR};PERL=${PERL_EXECUTABLE}"
362 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
363 # These tests use the same certificate corpus as x509_verify and can
364 # exceed the range of a 32-bit time_t.
365 if(SMALL_TIME_T)
366 set_property(TEST x509_callbacks PROPERTY WILL_FAIL TRUE)
367 endif()
368endif()
347 369
348# casttest 370# casttest
349add_executable(casttest casttest.c) 371add_executable(casttest casttest.c)
@@ -503,8 +525,6 @@ add_executable(exdata_test exdata_test.c)
503target_link_libraries(exdata_test ${OPENSSL_TEST_LIBS}) 525target_link_libraries(exdata_test ${OPENSSL_TEST_LIBS})
504add_platform_test(exdata_test exdata_test) 526add_platform_test(exdata_test exdata_test)
505 527
506# expirecallback.c
507
508# explicit_bzero 528# explicit_bzero
509# SA_ONSTACK is unavailable on Windows, sigsuspend is unavailable on Emscripten 529# SA_ONSTACK is unavailable on Windows, sigsuspend is unavailable on Emscripten
510if(NOT (WIN32 OR EMSCRIPTEN)) 530if(NOT (WIN32 OR EMSCRIPTEN))
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 9d30359..aec438b 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -105,6 +105,7 @@ DISTCLEANFILES = pidwraptest.txt
105 105
106distclean-local: 106distclean-local:
107 rm -rf ssl_verify-certs 107 rm -rf ssl_verify-certs
108 rm -rf x509_callback-certs
108 rm -rf x509_verify-certs 109 rm -rf x509_verify-certs
109 110
110# XXX - should probably be in their own static lib 111# XXX - should probably be in their own static lib
@@ -365,8 +366,21 @@ TESTS += bytestringtest
365check_PROGRAMS += bytestringtest 366check_PROGRAMS += bytestringtest
366bytestringtest_SOURCES = bytestringtest.c 367bytestringtest_SOURCES = bytestringtest.c
367 368
368# callback 369# x509_callbacks
369# callbackfailures 370if HAVE_PERL
371# These tests use the same certificate corpus as x509_verify and can exceed
372# the range of a 32-bit time_t.
373if SMALL_TIME_T
374XFAIL_TESTS += x509_callbacks.sh
375endif
376TESTS += x509_callbacks.sh
377check_PROGRAMS += callback callbackfailures expirecallback
378endif
379callback_SOURCES = callback.c
380callbackfailures_SOURCES = callbackfailures.c
381expirecallback_SOURCES = expirecallback.c
382EXTRA_DIST += x509_callbacks.sh
383EXTRA_DIST += callback.pl
370 384
371# casttest 385# casttest
372TESTS += casttest 386TESTS += casttest
@@ -524,8 +538,6 @@ TESTS += exdata_test
524check_PROGRAMS += exdata_test 538check_PROGRAMS += exdata_test
525exdata_test_SOURCES = exdata_test.c 539exdata_test_SOURCES = exdata_test.c
526 540
527# expirecallback.c
528
529# explicit_bzero 541# explicit_bzero
530# explicit_bzero relies on SA_ONSTACK, which is unavailable on Windows 542# explicit_bzero relies on SA_ONSTACK, which is unavailable on Windows
531if !HOST_WIN 543if !HOST_WIN
diff --git a/tests/x509_callbacks.sh b/tests/x509_callbacks.sh
new file mode 100755
index 0000000..a48e638
--- /dev/null
+++ b/tests/x509_callbacks.sh
@@ -0,0 +1,94 @@
1#!/bin/sh
2#
3# Copyright (c) 2026 Kenjiro Nakayama
4#
5# Permission to use, copy, modify, and distribute this software for any
6# purpose with or without fee is hereby granted, provided that the above
7# copyright notice and this permission notice appear in all copies.
8#
9# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16
17set -e
18
19if [ -z "$srcdir" ]; then
20 srcdir=.
21fi
22
23if [ -z "$PERL" ]; then
24 PERL=perl
25fi
26
27case "$srcdir" in
28/*)
29 certs_path="$srcdir/certs"
30 ca_file="$srcdir/../cert.pem"
31 callback_check="$srcdir/callback.pl"
32 make_dir_roots="$srcdir/make-dir-roots.pl"
33 openssl_conf="$srcdir/openssl.cnf"
34 ;;
35*)
36 certs_path="`pwd`/$srcdir/certs"
37 ca_file="`pwd`/$srcdir/../cert.pem"
38 callback_check="`pwd`/$srcdir/callback.pl"
39 make_dir_roots="`pwd`/$srcdir/make-dir-roots.pl"
40 openssl_conf="`pwd`/$srcdir/openssl.cnf"
41 ;;
42esac
43
44if [ $# -ge 3 ]; then
45 callback_bin=$1
46 callbackfailures_bin=$2
47 expirecallback_bin=$3
48else
49 callback_bin="`pwd`/callback"
50 callbackfailures_bin="`pwd`/callbackfailures"
51 expirecallback_bin="`pwd`/expirecallback"
52 if [ -e ./callback.exe ]; then
53 callback_bin="`pwd`/callback.exe"
54 callbackfailures_bin="`pwd`/callbackfailures.exe"
55 expirecallback_bin="`pwd`/expirecallback.exe"
56 fi
57fi
58
59if [ $# -ge 4 ]; then
60 openssl_dir=`dirname "$4"`
61elif [ -d ../apps/openssl ]; then
62 openssl_dir="`pwd`/../apps/openssl"
63else
64 openssl_dir="`pwd`/../apps"
65fi
66
67PATH="$openssl_dir:$PATH"
68export PATH
69
70if [ -f "$openssl_conf" ]; then
71 OPENSSL_CONF="$openssl_conf"
72 export OPENSSL_CONF
73fi
74
75workdir=x509_callback-certs
76
77cleanup()
78{
79 rm -rf "$workdir"
80}
81trap cleanup EXIT
82
83rm -rf "$workdir"
84mkdir "$workdir"
85
86"$PERL" "$make_dir_roots" "$certs_path" "$workdir"
87
88(
89 cd "$workdir"
90 "$callback_bin" "$certs_path"
91 "$PERL" "$callback_check" callback.out
92 "$callbackfailures_bin" "$certs_path" "$ca_file"
93 "$expirecallback_bin" "$certs_path"
94)
diff --git a/update.sh b/update.sh
index 83864d3..b863d4a 100755
--- a/update.sh
+++ b/update.sh
@@ -342,6 +342,7 @@ $CP $libcrypto_regress/evp/evptests.txt tests
342$CP $libcrypto_regress/aead/*.txt tests 342$CP $libcrypto_regress/aead/*.txt tests
343$CP $libcrypto_regress/ct/ctlog.conf tests 343$CP $libcrypto_regress/ct/ctlog.conf tests
344$CP $libcrypto_regress/ct/*.crt tests 344$CP $libcrypto_regress/ct/*.crt tests
345$CP $libcrypto_regress/x509/callback.pl tests
345$CP $libcrypto_regress/x509/make-dir-roots.pl tests 346$CP $libcrypto_regress/x509/make-dir-roots.pl tests
346rm -rf tests/certs 347rm -rf tests/certs
347mkdir -p tests/certs 348mkdir -p tests/certs