Skip to content

fix(tls): gate pre-1.1.0 OpenSSL deprecated APIs for OpenSSL 4.0 readiness - #388

Merged
fcostaoliveira merged 1 commit into
redis:masterfrom
filipecosta90:fix/openssl-4.0-readiness
May 25, 2026
Merged

fcostaoliveira merged 1 commit into
redis:masterfrom
filipecosta90:fix/openssl-4.0-readiness

Conversation

@fcostaoliveira

@fcostaoliveira fcostaoliveira commented May 19, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Closes #387.

OpenSSL 4.0 is on track to remove a number of APIs that were deprecated back in 1.1.0. memtier still called six of them unconditionally — SSLv23_client_method(), SSL_library_init(), SSL_load_error_strings(), CRYPTO_set_id_callback(), CRYPTO_set_locking_callback(), CRYPTO_num_locks(). Against modern OpenSSL these emit deprecation warnings; against OpenSSL 4.0 (or any distro that adds -Werror=deprecated-declarations downstream, as Redis does — see redis/redis#15221) the build will fail outright.

Gate the legacy locking-callback and init paths behind OPENSSL_VERSION_NUMBER < 0x10100000L — matching the existing OPENSSL_config / OPENSSL_init_crypto gate that was already in this file — and switch SSLv23_client_method → TLS_client_method on 1.1.0+.

The library has handled internal locking automatically since 1.1.0, and SSL_library_init / SSL_load_error_strings are no-ops since the same release, so dropping them on the modern path is a true no-op functionally.

Why this matters

  • OpenSSL 4.0 with -Werror=deprecated-declarations: hard build failure.
  • OpenSSL 4.0 that fully removes the symbols: link failure even without -Werror.
  • OpenSSL 3.x today: ~6 deprecation warnings on every TLS build.

Verification

Built locally with stricter flags to confirm the deprecation surface is gone:

make clean
CXXFLAGS="-O2 -g -Wall -Werror=deprecated-declarations" make -j4

→ build succeeds (only the pre-existing unrelated statsd.cpp -Wformat-truncation warning remains).

Test plan

  • Local build clean with -Werror=deprecated-declarations
  • Existing TLS test matrix (Single Endpoint TCP TLS, OSS TCP TLS v1.2 / v1.3, OSS-CLUSTER TCP TLS) under ASAN / UBSan / TSAN
  • No behavior change on OpenSSL 1.0.x (legacy path preserved)

🤖 Generated with Claude Code


Note

Low Risk
Low risk: changes are compile-time gated and primarily affect build compatibility with OpenSSL 1.1.0+ / 4.0 deprecations, with minimal runtime behavior impact beyond TLS context method selection.

Overview
Improves OpenSSL 1.1.0+ / 4.0 build compatibility for TLS builds. The legacy OpenSSL thread-locking callbacks and deprecated init calls are now compiled only for OPENSSL_VERSION_NUMBER < 0x10100000L, while newer versions use OPENSSL_init_crypto.

For TLS context creation, OpenSSL 1.1.0+ switches from SSLv23_client_method() to TLS_client_method(), keeping the older method on pre-1.1.0.

Reviewed by Cursor Bugbot for commit b3178a6. Bugbot is set up for automated code reviews on this repo. Configure here.

OpenSSL 4.0 is on track to remove a number of APIs that were deprecated
back in 1.1.0. memtier was still calling six of them unconditionally:

  - SSLv23_client_method()
  - SSL_library_init()
  - SSL_load_error_strings()
  - CRYPTO_set_id_callback() / CRYPTO_set_locking_callback()
  - CRYPTO_num_locks()

Against modern OpenSSL these emit deprecation warnings; against OpenSSL
4.0 (or any distro that adds -Werror=deprecated-declarations downstream,
as Redis does) the build will fail outright. The library has handled
internal locking automatically since 1.1.0, and SSL_library_init /
SSL_load_error_strings are no-op since the same release.

Gate the legacy locking and init path behind OPENSSL_VERSION_NUMBER <
0x10100000L (matching the existing OPENSSL_config / OPENSSL_init_crypto
gate that was already in this file) and switch SSLv23_client_method to
TLS_client_method on 1.1.0+.

Verified clean build with CXXFLAGS="-O2 -g -Wall \
-Werror=deprecated-declarations".

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@fcostaoliveira
fcostaoliveira merged commit 1cbaf70 into redis:master May 25, 2026
64 of 65 checks passed
@fcostaoliveira fcostaoliveira added this to the 2.4 milestone Jun 1, 2026
fcostaoliveira added a commit that referenced this pull request Jun 2, 2026
…nSSL 4.0 compat) (#432)

* fix(tls): replace SSL_OP_NO_TLSv1/1_1 with set_min_proto_version (OpenSSL 4.0 compat)

SSL_OP_NO_TLSv1 and SSL_OP_NO_TLSv1_1 are absent from the OpenSSL 4.0
public API. PR #388 covered the threading/init deprecations but missed
these two flags, so master would fail to build against OpenSSL 4.0.

SSL_CTX_set_min_proto_version / SSL_CTX_set_max_proto_version are
semantically equivalent (enforcing the user-requested protocol range)
and are available since OpenSSL 1.1.0. SSL_OP_NO_TLSv1_2 (also removed
in 4.0) is covered by the same guard. Falls back to SSL_OP_NO_TLSv* on
pre-1.1.0 toolchains.

Refs: 2.4 review finding #17

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* fix(tls): mask protocol gaps inside min/max range under OpenSSL >= 1.1.0

Bugbot flagged that the min/max approach allowed intermediate
protocols the user explicitly omitted (e.g. --tls-protocols
"tlsv1,tlsv1.2" enabled tlsv1.1).

Combines envelope clamp (set_min/max_proto_version) with per-gap
SSL_OP_NO_TLSv1_x masks, guarded by #ifdef so OpenSSL 4.0 (which may
remove the symbols entirely) still builds. For 4.0 the gap-mask is
silently skipped: removing those symbols means the runtime can't
individually disable them anyway, which matches OpenSSL's intended
deprecation policy.

Refs: bugbot MED review on PR #432

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

---------

Co-authored-by: Claude Sonnet 4.6 <[email protected]>
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 4.0 readiness: replace pre-1.1.0 deprecated APIs

2 participants