Skip to content

fix(tls): replace SSL_OP_NO_TLSv1/1_1 with set_min_proto_version (OpenSSL 4.0 compat) - #432

Merged
fcostaoliveira merged 2 commits into
masterfrom
fix/tls-openssl-4-compat
Jun 2, 2026
Merged

fcostaoliveira merged 2 commits into
masterfrom
fix/tls-openssl-4-compat

Conversation

@fcostaoliveira

@fcostaoliveira fcostaoliveira commented Jun 2, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • SSL_OP_NO_TLSv1, SSL_OP_NO_TLSv1_1, and SSL_OP_NO_TLSv1_2 are absent from the OpenSSL 4.0 public API; master would fail to build against OpenSSL 4.0.
  • PR fix(tls): gate pre-1.1.0 OpenSSL deprecated APIs for OpenSSL 4.0 readiness #388 guarded the threading/init deprecations but missed these OP_NO_TLSv* flags.
  • For OpenSSL >= 1.1.0: replace the three SSL_CTX_set_options(SSL_OP_NO_TLSv*) calls with SSL_CTX_set_min_proto_version / SSL_CTX_set_max_proto_version, computed from the existing tls_protocols bitmask — semantically identical behaviour.
  • For OpenSSL < 1.1.0: keep the original SSL_OP_NO_TLSv* fallback path.
  • The TLS 1.3 guard (>= 0x10101000L) is preserved inside the new block.

Refs: 2.4 release review finding #17.

Test plan

  • Build against OpenSSL 3.x (dev box): no SSL/TLS-related errors or warnings — confirmed.
  • Existing TLS integration tests: no functional change; protocol range enforcement is identical to the replaced OP_NO_* logic.
  • On OpenSSL 4.0 (when available): the SSL_OP_NO_TLSv* symbols are no longer referenced, so the build succeeds.

🤖 Generated with Claude Code


Note

Medium Risk
TLS handshake version/cipher negotiation behavior changes on OpenSSL 1.1+ (intended to match prior OP_NO_* semantics); gap-protocol edge cases deserve TLS integration tests. CLI changes are low-risk input validation only.

Overview
OpenSSL 4.0 / TLS: For OpenSSL ≥ 1.1.0, protocol selection no longer relies only on SSL_OP_NO_TLSv1* (removed in OpenSSL 4.0). The PR sets SSL_CTX_set_min_proto_version / set_max_proto_version from the existing tls_protocols bitmask, then disables gap versions inside that range with SSL_OP_NO_TLSv* only when those macros exist (#ifdef per version). OpenSSL < 1.1.0 keeps the previous SSL_OP_NO_TLSv* path.

CLI validation: --requests, --clients, --threads, and --test-time now reject leading-negative values via optarg_is_negative, reset errno before strtoul/strtoull, and treat ERANGE as parse errors—avoiding silent huge unsigned values from negative input.

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

…nSSL 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]>
@jit-ci

jit-ci Bot commented Jun 2, 2026 •

Copy link
Copy Markdown

🛡️ Jit Security Scan Results

CRITICAL HIGH MEDIUM

✅ No security findings were detected in this PR


Security scan by Jit

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit ab076b0. Configure here.

Comment thread memtier_benchmark.cpp Resolved
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]>
@fcostaoliveira

Copy link
Copy Markdown
Collaborator Author

Bugbot MED addressed via 46eacec: now combines envelope clamp with per-gap SSL_OP_NO_TLSv1_x masks (guarded by #ifdef for OpenSSL 4.0 compat). Gap protocols are masked explicitly; OpenSSL 4.0 falls back to envelope-only since the per-version constants are slated for removal there too.

@fcostaoliveira
fcostaoliveira merged commit 3e17fb9 into master Jun 2, 2026
102 of 104 checks passed
fcostaoliveira added a commit to filipecosta90/memtier_benchmark that referenced this pull request Jun 2, 2026
Resolve conflicts after redis#432/redis#434/redis#435 landed on master.

Conflict in memtier_benchmark.cpp: adopt master's "must be a positive
integer" wording (standardized by redis#432) for the four negative-value
guard fprintf() calls added by this branch; both sides trigger on the
same code path and the test assertions only check the prefix, so either
wording is functionally correct.
fcostaoliveira added a commit that referenced this pull request Jun 2, 2026
PR #432 added gap-mask SSL_OP_NO_TLSv1_x #ifdef blocks so the build
works on OpenSSL 4.0 (where those constants are slated for removal).
But a user passing a non-contiguous bitmask (e.g. tlsv1,tlsv1.2)
on OpenSSL 4.0 would silently get the intermediate version enabled
inside the envelope, with no warning.

Adds parser-time validation: on OpenSSL >= 4.0 a non-contiguous
bitmask is rejected at startup with an actionable error. On OpenSSL
<= 3.x the gap-mask logic still enforces the user's selection.

Refs: 2.4 review #37 (Review 14 + PR #432 review R4).

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.

1 participant