OpenSSL 4 dropped the ENGINE API. Use pkcs11-provider for the key check and systemd-sbsign, and sbsign's --provider option from sbsigntools-0.9.5_p1 on. Signed-off-by: David Seifert <so…@gentoo.org> --- eclass/secureboot.eclass | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/eclass/secureboot.eclass b/eclass/secureboot.eclass index 15c86e58ffab0..a259ce362833f 100644 --- a/eclass/secureboot.eclass +++ b/eclass/secureboot.eclass @@ -65,7 +65,8 @@ BDEPEND=" # @DEFAULT_UNSET # @DESCRIPTION: # Used with USE=secureboot. Should be set to the path of the private -# key in PEM format to use, or a PKCS#11 URI. +# key in PEM format to use, or a PKCS#11 URI. With OpenSSL 4, PKCS#11 +# URIs require dev-libs/pkcs11-provider. # If unspecified the following locations are tried in order: # - /etc/portage/secureboot.pem # - /var/lib/sbctl/keys/db/db.{key,pem} (from app-crypt/sbctl) @@ -201,7 +202,12 @@ secureboot_pkg_setup() { -noout -nocert ) if [[ ${SECUREBOOT_SIGN_KEY} == pkcs11:* ]]; then - openssl_args+=( -engine pkcs11 -keyform ENGINE -key "${SECUREBOOT_SIGN_KEY}" ) + # OpenSSL 4 removed the ENGINE API + if has_version -b ">=dev-libs/openssl-4"; then + openssl_args+=( -provider default -provider pkcs11 -key "${SECUREBOOT_SIGN_KEY}" ) + else + openssl_args+=( -engine pkcs11 -keyform ENGINE -key "${SECUREBOOT_SIGN_KEY}" ) + fi else openssl_args+=( -keyform PEM -key "${SECUREBOOT_SIGN_KEY}" ) fi @@ -243,7 +249,13 @@ secureboot_sign_efi_file() { "--cert=${SECUREBOOT_SIGN_CERT}" ) if [[ ${SECUREBOOT_SIGN_KEY} == pkcs11:* ]]; then - args+=( "--engine=pkcs11" ) + # 0.9.5_p1 replaced --engine with --provider + if has_version -b ">=app-crypt/sbsigntools-0.9.5_p1"; then + # sbsign loads the default provider before this one + args+=( "--provider=pkcs11" ) + else + args+=( "--engine=pkcs11" ) + fi fi "${EPREFIX}/usr/bin/sbsign" "${input_file}" "${args[@]}" @@ -254,7 +266,12 @@ secureboot_sign_efi_file() { "--certificate=${SECUREBOOT_SIGN_CERT}" ) if [[ ${SECUREBOOT_SIGN_KEY} == pkcs11:* ]]; then - args+=( "--private-key-source=engine:pkcs11" ) + # OpenSSL 4 removed the ENGINE API + if has_version -b ">=dev-libs/openssl-4"; then + args+=( "--private-key-source=provider:pkcs11" ) + else + args+=( "--private-key-source=engine:pkcs11" ) + fi fi "${EPREFIX}/usr/lib/systemd/systemd-sbsign" sign "${input_file}" "${args[@]}"
-- 2.56.1