Skip to content

Only use the OpenSSL ENGINE API when built with PKCS#11 support - #139

Open
ricardosalveti wants to merge 1 commit into
uptane:masterfrom
ricardosalveti:openssl4
Open

ricardosalveti wants to merge 1 commit into
uptane:masterfrom
ricardosalveti:openssl4

Conversation

@ricardosalveti

Copy link
Copy Markdown
Collaborator

OpenSSL 4.0 removed the ENGINE implementation from libcrypto and only keeps the declarations in engine.h, so linking libaktualizr fails on the engine-backed key loading in Crypto::RSAPSSSign():

crypto.cc:149: undefined reference to 'ENGINE_load_private_key'

That path can only be reached when aktualizr is built with BUILD_P11, since the P11 engine is the only source of a non-null engine. Compile it only in that case, so builds without PKCS#11 support link against OpenSSL 4.0 while nothing changes for builds with it or with OpenSSL 3.x. A BUILD_P11 build against OpenSSL 4.0 now fails early with a clear compile-time error instead of an undefined reference at link time. Moving the PKCS#11 support itself to OpenSSL providers is a separate task.

OpenSSL 4.0 removed the ENGINE implementation from libcrypto and only
keeps the declarations in engine.h, so linking libaktualizr fails on
the engine-backed key loading in Crypto::RSAPSSSign():

  crypto.cc:149: undefined reference to 'ENGINE_load_private_key'

That path can only be reached when aktualizr is built with BUILD_P11,
since the P11 engine is the only source of a non-null engine. Compile
it only in that case, so builds without PKCS#11 support link against
OpenSSL 4.0 while nothing changes for builds with it or with OpenSSL
3.x. A BUILD_P11 build against OpenSSL 4.0 now fails early with a
clear compile-time error instead of an undefined reference at link
time. Moving the PKCS#11 support itself to OpenSSL providers is a
separate task.

Signed-off-by: Ricardo Salveti <ricardo.salveti@oss.qualcomm.com>
ricardosalveti added a commit to uptane/meta-updater that referenced this pull request Sep 10, 2026
OpenSSL 4.0 returns a const X509_NAME pointer from
X509_get_subject_name() and removed the ENGINE API from libcrypto, so
libaktualizr fails to compile and then to link:

  crypto.cc:625:45: error: invalid conversion from 'const X509_NAME*'
  to 'X509_NAME*' [-fpermissive]
  crypto.cc:149: undefined reference to 'ENGINE_load_private_key'

Add the const fix submitted as uptane/aktualizr#138 and the patch
submitted as uptane/aktualizr#139 that only compiles the engine-backed
key loading with BUILD_P11. Builds without the hsm feature now link
against OpenSSL 4.0; builds with it fail early at compile time until
the PKCS#11 support is ported to OpenSSL providers.

Assisted-by: Claude Code:claude-fable-5-1
Signed-off-by: Ricardo Salveti <ricardo.salveti@oss.qualcomm.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant