@@ -369,7 +369,7 @@ make install
369369OUT
370370}
371371
372- @test " install bundled OpenSSL" {
372+ @test " install bundled OpenSSL on Linux " {
373373 cached_tarball " openssl-1.1.1w" config
374374 cached_tarball " ruby-3.2.0" configure
375375
378378
379379 stub_repeated uname ' -s : echo Linux'
380380 stub_repeated brew false
381- stub cc ' -xc -E - : echo "OpenSSL 1.0.1a 1 Aug 2023"'
381+ stub cc ' -xc -E - : echo "OpenSSL 1.0.1a 1 Aug 2023"' # system_openssl_version
382382 stub openssl " version -d : echo 'OPENSSLDIR: \" ${TMP} /ssl\" '"
383383 stub_make_install " install_sw"
384384 stub_make_install
393393 unstub uname
394394 unstub brew
395395 unstub cc
396- # unstub openssl
396+ # Depending on certain system certificate files being present under /etc/,
397+ # `openssl version -d` might not have been called, so avoid unstubbing it
398+ # since that would verify the number of invocations.
399+ # unstub openssl
397400 unstub make
398401
399402 assert_build_log << OUT
@@ -406,6 +409,54 @@ make install
406409OUT
407410}
408411
412+ @test " install bundled OpenSSL on macOS" {
413+ cached_tarball " openssl-1.1.1w" config
414+ cached_tarball " ruby-3.2.0" configure
415+
416+ stub_repeated uname ' -s : echo Darwin'
417+ stub security \
418+ ' find-certificate -a -p /Library/Keychains/System.keychain : echo "System.keychain"' \
419+ ' find-certificate -a -p /System/Library/Keychains/SystemRootCertificates.keychain : echo "SystemRootCertificates.keychain"'
420+ stub_repeated brew false
421+ stub cc ' -xc -E - : echo "OpenSSL 1.0.1a 1 Aug 2023"' # system_openssl_version
422+ stub openssl
423+ stub_make_install " install_sw"
424+ stub_make_install
425+
426+ mkdir -p " $INSTALL_ROOT " /openssl/ssl # OPENSSLDIR
427+ run_inline_definition << DEF
428+ install_package "openssl-1.1.1w" "https://www.openssl.org/source/openssl-1.1.1w.tar.gz" openssl --if needs_openssl_102_300
429+ install_package "ruby-3.2.0" "http://ruby-lang.org/ruby/2.0/ruby-3.2.0.tar.gz"
430+ DEF
431+ assert_success
432+
433+ unstub uname
434+ unstub security
435+ unstub brew
436+ # Depending on the state of system `/usr/bin/openssl` in the test runner,
437+ # `cc` might not have been called, so avoid unstubbing it since that would
438+ # verify the number of invocations.
439+ # unstub cc
440+ unstub openssl
441+ unstub make
442+
443+ # No rpath on macOS, OpenSSL sets it itself: https://wiki.openssl.org/index.php/Compilation_and_Installation#Using_RPATHs
444+ assert_build_log << OUT
445+ openssl-1.1.1w: [--prefix=${INSTALL_ROOT} /openssl,--openssldir=${INSTALL_ROOT} /openssl/ssl,--libdir=lib,zlib-dynamic,no-ssl3,shared]
446+ make -j 2
447+ make install_sw install_ssldirs
448+ ruby-3.2.0: [--prefix=$INSTALL_ROOT ,--with-openssl-dir=$INSTALL_ROOT /openssl,--with-ext=openssl,psych,+] PKG_CONFIG_PATH=${TMP} /install/openssl/lib/pkgconfig
449+ PKG_CONFIG_PATH=${TMP} /install/openssl/lib/pkgconfig make -j 2
450+ make install
451+ OUT
452+
453+ run cat " $INSTALL_ROOT " /openssl/ssl/cert.pem
454+ assert_output << PEM
455+ System.keychain
456+ SystemRootCertificates.keychain
457+ PEM
458+ }
459+
409460@test " skip bundling OpenSSL if custom openssl dir was specified" {
410461 cached_tarball " ruby-3.2.0" configure
411462
0 commit comments