Skip to content

OpenSSL build fixes with various no-opt. #634

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 25, 2025

Conversation

pluknet
Copy link
Contributor

@pluknet pluknet commented Apr 16, 2025

Closes #620.

@jasonmader
Copy link

These changes worked for my build.

@pluknet
Copy link
Contributor Author

pluknet commented Apr 16, 2025

These changes worked for my build.

Ok, thanks for testing.

@bavshin-f5
Copy link
Member

Looks good, just two questions:

  • Do we care about OpenSSL before 3.0 built with no-dh?
  • Do you want to check OPENSSL_NO_DH before including openssl/dh.h? DH_free is the only symbol we use from this header.

I briefly wondered about the lifetime expectancy for the OPENSSL_NO_DEPRECATED_X_Y macros, but I doubt we'll learn that before the OpenSSL 4.0 release next year. No reason to worry about it right now.

@pluknet
Copy link
Contributor Author

pluknet commented Apr 24, 2025

I briefly wondered about the lifetime expectancy for the OPENSSL_NO_DEPRECATED_X_Y macros, but I doubt we'll learn that before the OpenSSL 4.0 release next year. No reason to worry about it right now.

They are documented in the internal deprecation.pod:

B<OSSL_DEPRECATEDIN_I<version>> and B<OPENSSL_NO_DEPRECATED_I<version>> are
defined in F<< <openssl/macros.h> >>.

In those macro names, B<I<version>> corresponds to the OpenSSL release since
which the deprecation applies

And further in openssl/macros.h:

 * The macros OPENSSL_NO_DEPRECATED_{major}_{minor} are defined for
 * all OpenSSL versions up to or equal to the version given with
 * OPENSSL_API_COMPAT.  They are used as guards around anything that's
 * deprecated up to that version, as an effect of the developer option
 * 'no-deprecated'.
 */

So we can assume that at least the macros won't be renamed.
What concerns me is that they are not publicly documented.

The current scheme of testing OPENSSL_NO_DEPRECATED and OPENSSL_VERSION_NUMBER
is used to work as well to some extent.

The difference is that OPENSSL_NO_DEPRECATED_X_Y better suites our needs
when OPENSSL_NO_DEPRECATED is defined but OPENSSL_API_LEVEL is set lower than a tested version.

For example, using SSL_SESSION_get_time in OpenSSL 3.5 deprecated in 3.4:

  1. #if (OPENSSL_VERSION_NUMBER >= 0x3040000fL && defined OPENSSL_NO_DEPRECATED)
case defined used
OPENSSL_API_LEVEL=10100 yes SSL_SESSION_get_time
OPENSSL_API_LEVEL=10100 no-deprecated yes SSL_SESSION_get_time_ex
OPENSSL_API_LEVEL=30500 yes SSL_SESSION_get_time
OPENSSL_API_LEVEL=30500 no-deprecated no SSL_SESSION_get_time_ex
  1. #ifdef OPENSSL_NO_DEPRECATED_3_4
case defined used
OPENSSL_API_LEVEL=10100 yes SSL_SESSION_get_time
OPENSSL_API_LEVEL=10100 no-deprecated yes SSL_SESSION_get_time
OPENSSL_API_LEVEL=30500 yes SSL_SESSION_get_time
OPENSSL_API_LEVEL=30500 no-deprecated no SSL_SESSION_get_time_ex

As emphasized above, the current scheme[1] suffers in that case.
Specifically, SSL_SESSION_get_time() declaration is "redefined" by our macro to the _ex version,
as seen from cc -E -DOPENSSL_NO_DEPRECATED -DOPENSSL_API_COMPAT=0x10100000L ... src/event/ngx_event_openssl.c:

       long SSL_SESSION_get_time(const SSL_SESSION *s);
...
            time = SSL_SESSION_get_time_ex(sess);

This is used to work until SSL_SESSION_get_time() becomes a macro for some reason.
Amending with undef to make this future-proof looks somewhat superfluous though.

@pluknet
Copy link
Contributor Author

pluknet commented Apr 24, 2025

* Do we care about OpenSSL before 3.0 built with `no-dh`?

* Do you want to check `OPENSSL_NO_DH` before including `openssl/dh.h`? `DH_free` is the only symbol we use from this header.

Fixed, thanks.

@pluknet pluknet merged commit adda704 into nginx:master Apr 25, 2025
1 check passed
@pluknet pluknet deleted the openssl-no-opt branch April 25, 2025 10:56
@Maryna-f5 Maryna-f5 added this to the nginx-1.27.6 milestone Apr 25, 2025
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.

OpenSSL 3.5.0: undeclared function 'SSL_SESSION_get_time'
4 participants