Bug 68080 - OPENSSL_NO_ENGINE from openssl/opensslconf.h ignored
Summary: OPENSSL_NO_ENGINE from openssl/opensslconf.h ignored
Status: RESOLVED FIXED
Alias: None
Product: Apache httpd-2
Classification: Unclassified
Component: mod_ssl (show other bugs)
Version: 2.4-HEAD
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: Apache HTTPD Bugs Mailing List
URL:
Keywords: FixedInTrunk
Depends on:
Blocks:
 
Reported: 2023-11-05 11:16 UTC by Bernard Spil
Modified: 2023-11-18 11:34 UTC (History)
0 users



Attachments
unified diff for acinclude.m4 (1.30 KB, patch)
2023-11-05 12:18 UTC, Bernard Spil
Details | Diff
Unset MODSSL_HAVE_ENGINE_API for OPENSSL_NO_ENGINE (1004 bytes, patch)
2023-11-06 09:58 UTC, Yann Ylavic
Details | Diff
allow SSLCryptoDevice builtin to be configured w/o any ENGINE support in openSSL (1.34 KB, patch)
2023-11-15 14:43 UTC, Joe Orton
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Bernard Spil 2023-11-05 11:16:14 UTC
Building with OpenSSL libraries that have OPENSSL_NO_ENGINE set in openssl/opensslconf.h fail.

> --- ssl_engine_config.slo ---
> ssl_engine_config.c:618:13: warning: call to undeclared function 'ENGINE_get_first'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
>         e = ENGINE_get_first();
>             ^
> ssl_engine_config.c:618:11: error: incompatible integer to pointer conversion assigning to 'ENGINE *' (aka 'struct engine_st *') from 'int' [-Wint-conversion]
>         e = ENGINE_get_first();
>           ^ ~~~~~~~~~~~~~~~~~~
> ssl_engine_config.c:624:17: warning: call to undeclared function 'ENGINE_get_next'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
>             e = ENGINE_get_next(e);
>                 ^
> ssl_engine_config.c:624:15: error: incompatible integer to pointer conversion assigning to 'ENGINE *' (aka 'struct engine_st *') from 'int' [-Wint-conversion]
>             e = ENGINE_get_next(e);
>               ^ ~~~~~~~~~~~~~~~~~~
> 2 warnings and 2 errors generated.

Full build log https://brnrd.eu/poudriere/data/140libre-default/2023-11-04_19h07m11s/logs/errors/apache24-2.4.58_1.log

Apache 2.4.58
FreeBSD 14.0-RC4
LibreSSL 3.8.2
apr 1.7.3
apr-utils 1.6.3
clang version 16.0.6
autoconf 2.71

Context from https://ftp.openbsd.org/pub/OpenBSD/LibreSSL/libressl-3.8.1-relnotes.txt
>    - ENGINE support was removed and OPENSSL_NO_ENGINE is set. In spite
>      of this, some stub functions are provided to avoid patching some
>      applications that do not honor OPENSSL_NO_ENGINE.
which unfortunately fails.

Workaround is to set ac_cv_func_ENGINE_init=no in configure environment, see https://cvsweb.openbsd.org/cgi-bin/cvsweb/~checkout~/ports/www/apache-httpd/Makefile?rev=1.126.2.2&content-type=text/plain
Comment 1 Bernard Spil 2023-11-05 12:18:46 UTC
Created attachment 39346 [details]
unified diff for acinclude.m4

Check for OPENSSL_NO_ENGINE flag before running other engine checks in autoconf.

tested with 
 * LibreSSL 3.8.2
 * OpenSSL 3.0.12 `Configure enable-engine`
 * OpenSSL 3.0.12 `Configure disable-engine` (sets OPENSSL_NO_ENGINE)
Comment 2 Yann Ylavic 2023-11-06 09:58:46 UTC
Created attachment 39349 [details]
Unset MODSSL_HAVE_ENGINE_API for OPENSSL_NO_ENGINE

I'm wondering if we still want to allow for "SSLCryptoDevice builtin" when OPENSSL_NO_ENGINE is set. I don't know how much this setting is used nor if we should care, but given that "builtin" is the same as no SSLCryptoDevice maybe we could still let httpd start even if it's built against openssl >= 3 or OPENSSL_NO_ENGINE.
The ENGINE api is deprecated in openssl >= 3 so in r1908537 we defined/used MODSSL_HAVE_ENGINE_API to compile out any code using it, maybe we could do that too for OPENSSL_NO_ENGINE like in the this patch? Does it work for your case?
Comment 3 Joe Orton 2023-11-15 14:41:28 UTC
(In reply to Yann Ylavic from comment #2)
> Created attachment 39349 [details]
> Unset MODSSL_HAVE_ENGINE_API for OPENSSL_NO_ENGINE

+1

> I'm wondering if we still want to allow for "SSLCryptoDevice builtin" when
> OPENSSL_NO_ENGINE is set. I don't know how much this setting is used nor if
> we should care, but given that "builtin" is the same as no SSLCryptoDevice
> maybe we could still let httpd start even if it's built against openssl >= 3
> or OPENSSL_NO_ENGINE.

+1, and removing the:

#if defined(HAVE_OPENSSL_ENGINE_H) && defined(HAVE_ENGINE_INIT)

should do it?

> The ENGINE api is deprecated in openssl >= 3 so in r1908537 we defined/used
> MODSSL_HAVE_ENGINE_API to compile out any code using it, maybe we could do
> that too for OPENSSL_NO_ENGINE like in the this patch? Does it work for your
> case?
Comment 4 Joe Orton 2023-11-15 14:43:13 UTC
Created attachment 39370 [details]
allow SSLCryptoDevice builtin to be configured w/o any ENGINE support in openSSL
Comment 5 Bernard Spil 2023-11-15 18:36:15 UTC
(In reply to Yann Ylavic from comment #2)
> Created attachment 39349 [details]
> Unset MODSSL_HAVE_ENGINE_API for OPENSSL_NO_ENGINE
> 
> I'm wondering if we still want to allow for "SSLCryptoDevice builtin" when
> OPENSSL_NO_ENGINE is set. I don't know how much this setting is used nor if
> we should care, but given that "builtin" is the same as no SSLCryptoDevice
> maybe we could still let httpd start even if it's built against openssl >= 3
> or OPENSSL_NO_ENGINE.
> The ENGINE api is deprecated in openssl >= 3 so in r1908537 we defined/used
> MODSSL_HAVE_ENGINE_API to compile out any code using it, maybe we could do
> that too for OPENSSL_NO_ENGINE like in the this patch? Does it work for your
> case?

The 2.4.x branch does not have MODSSL_HAVE_ENGINE_API at all, any hint on what branch to test that is similar to what I can expect to see as 2.4.59?
 
I'm trying to create a patch for the FreeBSD port (I'm part of the apache team in FreeBSD ports). May well go with OpenBSD's solution: settubg ac_cv_func_ENGINE_init=no in configure's env. (https://cvsweb.openbsd.org/cgi-bin/cvsweb/~checkout~/ports/www/apache-httpd/Makefile?rev=1.126.2.2&content-type=text/plain).
Comment 6 Yann Ylavic 2023-11-15 21:38:37 UTC
(In reply to Bernard Spil from comment #5)
> (In reply to Yann Ylavic from comment #2)
> > Created attachment 39349 [details]
> > Unset MODSSL_HAVE_ENGINE_API for OPENSSL_NO_ENGINE
> > 
> > I'm wondering if we still want to allow for "SSLCryptoDevice builtin" when
> > OPENSSL_NO_ENGINE is set. I don't know how much this setting is used nor if
> > we should care, but given that "builtin" is the same as no SSLCryptoDevice
> > maybe we could still let httpd start even if it's built against openssl >= 3
> > or OPENSSL_NO_ENGINE.
> > The ENGINE api is deprecated in openssl >= 3 so in r1908537 we defined/used
> > MODSSL_HAVE_ENGINE_API to compile out any code using it, maybe we could do
> > that too for OPENSSL_NO_ENGINE like in the this patch? Does it work for your
> > case?
> 
> The 2.4.x branch does not have MODSSL_HAVE_ENGINE_API at all, any hint on
> what branch to test that is similar to what I can expect to see as 2.4.59?

There is https://github.com/apache/httpd/pull/381 which is a backport I plan to propose for the next release.
Comment 7 Yann Ylavic 2023-11-15 22:10:05 UTC
(In reply to Joe Orton from comment #4)
> Created attachment 39370 [details]
> allow SSLCryptoDevice builtin to be configured w/o any ENGINE support in
> openSSL

Thanks Joe, I pushed the whole in r1913815.
Comment 8 Yann Ylavic 2023-11-15 22:21:05 UTC
> There is https://github.com/apache/httpd/pull/381 which is a backport I plan
> to propose for the next release.

r1913815 is now included in this PR, so the full patch would be:
https://patch-diff.githubusercontent.com/raw/apache/httpd/pull/381.diff
Comment 9 Yann Ylavic 2023-11-16 12:07:39 UTC
Proposed for backport to 2.4.x (r1913834).
Comment 10 Graham Leggett 2023-11-18 11:34:54 UTC
Backported to v2.4.59.