diff options
| author | Theo Buehler <tb@openbsd.org> | 2026-07-31 09:29:16 +0200 |
|---|---|---|
| committer | Theo Buehler <tb@openbsd.org> | 2026-07-31 09:29:16 +0200 |
| commit | 3c46654fb6b3082e2835d6250320fa9cdd50a077 (patch) | |
| tree | 09165d046f459b8ff77475b88332a1edfd2359da | |
| parent | 0ab79b7c8111fce123821c752655c7e6e55110f8 (diff) | |
| parent | a10cbdaf4fb6d11f741464ef162c1ffdeeb926b2 (diff) | |
| download | portable-3c46654fb6b3082e2835d6250320fa9cdd50a077.tar.gz portable-3c46654fb6b3082e2835d6250320fa9cdd50a077.tar.bz2 portable-3c46654fb6b3082e2835d6250320fa9cdd50a077.zip | |
Land #1343 - hook up x509 callback tests
| -rw-r--r-- | tests/CMakeLists.txt | 28 | ||||
| -rw-r--r-- | tests/Makefile.am | 20 | ||||
| -rwxr-xr-x | tests/x509_callbacks.sh | 94 | ||||
| -rwxr-xr-x | update.sh | 1 |
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) | |||
| 342 | target_link_libraries(bytestringtest ${OPENSSL_TEST_LIBS}) | 342 | target_link_libraries(bytestringtest ${OPENSSL_TEST_LIBS}) |
| 343 | add_platform_test(bytestringtest bytestringtest) | 343 | add_platform_test(bytestringtest bytestringtest) |
| 344 | 344 | ||
| 345 | # callback | 345 | # x509_callbacks |
| 346 | # callbackfailures | 346 | add_executable(callback callback.c) |
| 347 | target_link_libraries(callback ${OPENSSL_TEST_LIBS}) | ||
| 348 | add_executable(callbackfailures callbackfailures.c) | ||
| 349 | target_link_libraries(callbackfailures ${OPENSSL_TEST_LIBS}) | ||
| 350 | add_executable(expirecallback expirecallback.c) | ||
| 351 | target_link_libraries(expirecallback ${OPENSSL_TEST_LIBS}) | ||
| 352 | add_dependencies(callback openssl) | ||
| 353 | if(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() | ||
| 368 | endif() | ||
| 347 | 369 | ||
| 348 | # casttest | 370 | # casttest |
| 349 | add_executable(casttest casttest.c) | 371 | add_executable(casttest casttest.c) |
| @@ -503,8 +525,6 @@ add_executable(exdata_test exdata_test.c) | |||
| 503 | target_link_libraries(exdata_test ${OPENSSL_TEST_LIBS}) | 525 | target_link_libraries(exdata_test ${OPENSSL_TEST_LIBS}) |
| 504 | add_platform_test(exdata_test exdata_test) | 526 | add_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 |
| 510 | if(NOT (WIN32 OR EMSCRIPTEN)) | 530 | if(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 | ||
| 106 | distclean-local: | 106 | distclean-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 | |||
| 365 | check_PROGRAMS += bytestringtest | 366 | check_PROGRAMS += bytestringtest |
| 366 | bytestringtest_SOURCES = bytestringtest.c | 367 | bytestringtest_SOURCES = bytestringtest.c |
| 367 | 368 | ||
| 368 | # callback | 369 | # x509_callbacks |
| 369 | # callbackfailures | 370 | if 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. | ||
| 373 | if SMALL_TIME_T | ||
| 374 | XFAIL_TESTS += x509_callbacks.sh | ||
| 375 | endif | ||
| 376 | TESTS += x509_callbacks.sh | ||
| 377 | check_PROGRAMS += callback callbackfailures expirecallback | ||
| 378 | endif | ||
| 379 | callback_SOURCES = callback.c | ||
| 380 | callbackfailures_SOURCES = callbackfailures.c | ||
| 381 | expirecallback_SOURCES = expirecallback.c | ||
| 382 | EXTRA_DIST += x509_callbacks.sh | ||
| 383 | EXTRA_DIST += callback.pl | ||
| 370 | 384 | ||
| 371 | # casttest | 385 | # casttest |
| 372 | TESTS += casttest | 386 | TESTS += casttest |
| @@ -524,8 +538,6 @@ TESTS += exdata_test | |||
| 524 | check_PROGRAMS += exdata_test | 538 | check_PROGRAMS += exdata_test |
| 525 | exdata_test_SOURCES = exdata_test.c | 539 | exdata_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 |
| 531 | if !HOST_WIN | 543 | if !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 | |||
| 17 | set -e | ||
| 18 | |||
| 19 | if [ -z "$srcdir" ]; then | ||
| 20 | srcdir=. | ||
| 21 | fi | ||
| 22 | |||
| 23 | if [ -z "$PERL" ]; then | ||
| 24 | PERL=perl | ||
| 25 | fi | ||
| 26 | |||
| 27 | case "$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 | ;; | ||
| 42 | esac | ||
| 43 | |||
| 44 | if [ $# -ge 3 ]; then | ||
| 45 | callback_bin=$1 | ||
| 46 | callbackfailures_bin=$2 | ||
| 47 | expirecallback_bin=$3 | ||
| 48 | else | ||
| 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 | ||
| 57 | fi | ||
| 58 | |||
| 59 | if [ $# -ge 4 ]; then | ||
| 60 | openssl_dir=`dirname "$4"` | ||
| 61 | elif [ -d ../apps/openssl ]; then | ||
| 62 | openssl_dir="`pwd`/../apps/openssl" | ||
| 63 | else | ||
| 64 | openssl_dir="`pwd`/../apps" | ||
| 65 | fi | ||
| 66 | |||
| 67 | PATH="$openssl_dir:$PATH" | ||
| 68 | export PATH | ||
| 69 | |||
| 70 | if [ -f "$openssl_conf" ]; then | ||
| 71 | OPENSSL_CONF="$openssl_conf" | ||
| 72 | export OPENSSL_CONF | ||
| 73 | fi | ||
| 74 | |||
| 75 | workdir=x509_callback-certs | ||
| 76 | |||
| 77 | cleanup() | ||
| 78 | { | ||
| 79 | rm -rf "$workdir" | ||
| 80 | } | ||
| 81 | trap cleanup EXIT | ||
| 82 | |||
| 83 | rm -rf "$workdir" | ||
| 84 | mkdir "$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 | ) | ||
| @@ -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 |
| 346 | rm -rf tests/certs | 347 | rm -rf tests/certs |
| 347 | mkdir -p tests/certs | 348 | mkdir -p tests/certs |
