Skip to content

Fix compatibility for OpenSSL < 3.0 and Almalinux version mismatch for daily tests - #3303

Merged
enjoy-binbin merged 3 commits into
valkey-io:unstablefrom
roshkhatri:fix-tls-openssl-compat
Mar 5, 2026
Merged

enjoy-binbin merged 3 commits into
valkey-io:unstablefrom
roshkhatri:fix-tls-openssl-compat

Conversation

@roshkhatri

@roshkhatri roshkhatri commented Mar 4, 2026 •

Copy link
Copy Markdown
Member

SSL_get0_peer_certificate() was introduced in OpenSSL 3.0. The recent commit 7e110ae (Support TLS authentication using SAN URI) used it in tlsGetPeerUser() without a version guard, breaking builds against OpenSSL 1.1.x.

Use SSL_get_peer_certificate() on OpenSSL < 3.0 with the corresponding X509_free() since the older API increments the reference count.

Fixes build failure: implicit declaration of function SSL_get0_peer_certificate [-Werror=implicit-function-declaration]
https://github.com/valkey-io/valkey/actions/runs/22648954538/job/65643630947

Test run for this change: https://github.com/roshkhatri/valkey/actions/runs/22655187385
Screenshot 2026-03-03 at 8 49 43 PM
Screenshot 2026-03-03 at 8 50 27 PM

Also fixes the version mismatch for almalinux 9 daily tests: #3304

SSL_get0_peer_certificate() was introduced in OpenSSL 3.0. The recent
commit 7e110ae (Support TLS authentication using SAN URI) used it
in tlsGetPeerUser() without a version guard, breaking builds against
OpenSSL 1.1.x.

Use SSL_get_peer_certificate() on OpenSSL < 3.0 with the corresponding
X509_free() since the older API increments the reference count.

Fixes build failure: implicit declaration of function
'SSL_get0_peer_certificate' [-Werror=implicit-function-declaration]

Signed-off-by: Roshan Khatri <rvkhatri@amazon.com>
@roshkhatri
roshkhatri force-pushed the fix-tls-openssl-compat branch from d8bc778 to 4996dc9 Compare March 4, 2026 03:39
@roshkhatri roshkhatri self-assigned this Mar 4, 2026
@roshkhatri

Copy link
Copy Markdown
Member Author

@valkey-io/core-team PTAL

@yang-z-o

yang-z-o commented Mar 4, 2026 •

Copy link
Copy Markdown
Contributor

I originally used SSL_get_peer_certificate with X509_free, and then switched to SSL_get0_peer_certificate based on your feedback #3078 (comment).
However, it seems we still need to free for OpenSSL < 3.0 anyway.
Given that, would it be simpler and cleaner to revert to consistently using SSL_get_peer_certificate with X509_free?

@roshkhatri

roshkhatri commented Mar 4, 2026 •

Copy link
Copy Markdown
Member Author

I originally used SSL_get_peer_certificate with X509_free, and then switched to SSL_get0_peer_certificate based on your feedback #3078 (comment).

Yes I realized that I was the one who suggested it, but I didn't realize that is would fail in this case

I don't think we should remove SSL_get0_peer_certificate as SSL_get_peer_certificate is deprecated since OpenSSL 3.0.

So I think in fact we should change all the occurrences of SSL_get_peer_certificate to SSL_get0_peer_certificate

@roshkhatri roshkhatri changed the title Fix SSL_get0_peer_certificate compatibility for OpenSSL < 3.0 Fix compatibility for OpenSSL < 3.0 and Almalinux version mismatch for daily tests Mar 4, 2026
All test-almalinux9-* jobs were using container: almalinux:8 instead
of almalinux:9 since they were introduced in PR valkey-io#543 (May 2024).
This meant the AlmaLinux 9 jobs were actually testing AlmaLinux 8.

Signed-off-by: Roshan Khatri <rvkhatri@amazon.com>
Also fixes a pre-existing memory leak: SSL_get_peer_certificate()
increments the refcount but X509_free() was never called.

Signed-off-by: Roshan Khatri <rvkhatri@amazon.com>
@roshkhatri
roshkhatri force-pushed the fix-tls-openssl-compat branch from 48b62a1 to e7e6a7e Compare March 4, 2026 04:45

@yang-z-o yang-z-o left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Make sense, thanks!

@sarthakaggarwal97 sarthakaggarwal97 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM!

@enjoy-binbin
enjoy-binbin merged commit a731e45 into valkey-io:unstable Mar 5, 2026
56 checks passed
@codecov

codecov Bot commented Mar 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 0.00%. Comparing base (896e9c8) to head (e7e6a7e).
⚠️ Report is 2 commits behind head on unstable.

Additional details and impacted files
@@       Coverage Diff        @@
##   unstable   #3303   +/-   ##
================================
================================
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

eifrah-aws pushed a commit to eifrah-aws/valkey that referenced this pull request Mar 5, 2026
…r daily tests (valkey-io#3303)

`SSL_get0_peer_certificate()` was introduced in OpenSSL 3.0. The recent
commit 7e110ae (Support TLS authentication using SAN URI) used it in
`tlsGetPeerUser()` without a version guard, breaking builds against
`OpenSSL 1.1.x.`

Use `SSL_get_peer_certificate()` on OpenSSL < 3.0 with the corresponding
`X509_free()` since the older API increments the reference count.

Fixes build failure: implicit declaration of function
`SSL_get0_peer_certificate [-Werror=implicit-function-declaration]`

Also fixes the version mismatch for almalinux 9 daily tests.
Closes valkey-io#3304.

Signed-off-by: Roshan Khatri <rvkhatri@amazon.com>
hpatro pushed a commit to hpatro/valkey that referenced this pull request Mar 5, 2026
…r daily tests (valkey-io#3303)

`SSL_get0_peer_certificate()` was introduced in OpenSSL 3.0. The recent
commit 7e110ae (Support TLS authentication using SAN URI) used it in
`tlsGetPeerUser()` without a version guard, breaking builds against
`OpenSSL 1.1.x.`

Use `SSL_get_peer_certificate()` on OpenSSL < 3.0 with the corresponding
`X509_free()` since the older API increments the reference count.

Fixes build failure: implicit declaration of function
`SSL_get0_peer_certificate [-Werror=implicit-function-declaration]`

Also fixes the version mismatch for almalinux 9 daily tests.
Closes valkey-io#3304.

Signed-off-by: Roshan Khatri <rvkhatri@amazon.com>
Signed-off-by: Harkrishn Patro <bunty.hari@gmail.com>
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.

5 participants