Skip to content

THRIFT-6170: Fix TSSLSocket build with OpenSSL 4.0 - #3752

Open
jaipaulcheernam wants to merge 1 commit into
apache:masterfrom
jaipaulcheernam:fix-openssl4
Open

THRIFT-6170: Fix TSSLSocket build with OpenSSL 4.0#3752
jaipaulcheernam wants to merge 1 commit into
apache:masterfrom
jaipaulcheernam:fix-openssl4

Conversation

@jaipaulcheernam

@jaipaulcheernam jaipaulcheernam commented Aug 27, 2026

Copy link
Copy Markdown

OpenSSL 4.0 removes SSLv3_method() and per-version TLS method functions (TLSv1_method, TLSv1_1_method, TLSv1_2_method), the deprecated ASN1_STRING_data() function, and returns const pointers from X509_get_subject_name(), X509_NAME_get_entry(), and X509_NAME_ENTRY_get_data().

  • Guard SSLv3_method and TLS version methods with version check
  • Replace ASN1_STRING_data with ASN1_STRING_get0_data
  • Add const qualifiers for X509_NAME, X509_NAME_ENTRY, ASN1_STRING

This is backward-compatible with OpenSSL >= 1.1.0 since all replacement APIs exist since that version.

  • Did you create an Apache Jira ticket? (Request account here, not required for trivial changes)
  • If a ticket exists: Does your pull request title follow the pattern "THRIFT-NNNN: describe my issue"?
  • Did you squash your changes to a single commit? (not required, but preferred)
  • Did you do your best to avoid breaking changes? If one was needed, did you label the Jira ticket with "Breaking-Change"?
  • If your change does not involve any code, include [skip ci] anywhere in the commit message to free up build resources.

@mergeable mergeable Bot added the c++ Pull requests that update C++ code label Aug 27, 2026
@mergeable mergeable Bot added the c_glib label Aug 27, 2026
@Jens-G

Jens-G commented Aug 27, 2026

Copy link
Copy Markdown
Member

This branch has conflicts that must be resolved

@Jens-G Jens-G added the rebase needed rebase needed label Aug 27, 2026
@loqs

loqs commented Aug 27, 2026

Copy link
Copy Markdown

Is it expected that SecurityTest and SecurityFromBufferTest both hang/timeout with OpenSSL 4.0.2 and the test expectations will be changed in a future pull request?

OPENSSL_NO_SSL3 is not defined for OpenSSSL 4 so #ifdef OPENSSL_NO_SSL3 passes and the tests try to use SSL3 and timeout. TLSv1.0/1.1 require SSL_CTX_set_min_proto_version when using TLS_method instead of the per version method. Without it being set the TLSv1.0 and TLSv1.1 tests timeout like the SSL 3 tests.

kraj pushed a commit to YoeDistro/meta-openembedded that referenced this pull request Aug 28, 2026
OpenSSL 4.0 removes SSLv3_method(), per-version TLS method functions,
ERR_remove_state(), ASN1_STRING_data(), and returns const pointers
from X509 accessor functions. Fix both C++ and C GLib bindings.

Upstream-Status: Submitted [apache/thrift#3752]
Signed-off-by: Jaipaul Cheernam <jaipaul.cheernam@est.tech>
Signed-off-by: Khem Raj <khem.raj@oss.qualcomm.com>
OpenSSL 4.0 removes SSLv3_method(), per-version TLS method functions,
ERR_remove_state(), ASN1_STRING_data(), and returns const pointers
from X509 accessor functions.

C++ (TSSLSocket.cpp):
- Remove ERR_remove_state() calls (no-op since OpenSSL 1.1)
- Guard SSLv3_method with version check
- Use TLS_method() + SSL_CTX_set_min/max_proto_version() for
  TLSv1.0/1.1/1.2 on OpenSSL 4.0 (per-version methods removed)
- Replace ASN1_STRING_data with ASN1_STRING_get0_data
- Add const qualifiers for X509_NAME, X509_NAME_ENTRY, ASN1_STRING

C (thrift_ssl_socket.c):
- Remove ERR_remove_state() calls
- Guard SSLv3 and TLS version methods with version check

Signed-off-by: Jaipaul Cheernam <jaipaul.cheernam@est.tech>
@jaipaulcheernam

Copy link
Copy Markdown
Author

This branch has conflicts that must be resolved

Done. rebased and please check

@jaipaulcheernam

Copy link
Copy Markdown
Author

Is it expected that SecurityTest and SecurityFromBufferTest both hang/timeout with OpenSSL 4.0.2 and the test expectations will be changed in a future pull request?

OPENSSL_NO_SSL3 is not defined for OpenSSSL 4 so #ifdef OPENSSL_NO_SSL3 passes and the tests try to use SSL3 and timeout. TLSv1.0/1.1 require SSL_CTX_set_min_proto_version when using TLS_method instead of the per version method. Without it being set the TLSv1.0 and TLSv1.1 tests timeout like the SSL 3 tests.

Thanks for the feedback! Updated the PR:

  • Rebased onto latest master (conflicts resolved)
  • TLSv1.0/1.1/1.2 now use TLS_method() + SSL_CTX_set_min_proto_version() / SSL_CTX_set_max_proto_version() on OpenSSL 4.0, so tests should no longer hang
  • SSLv3 is guarded out on OpenSSL 4.0 (returns error since the protocol is truly removed)
  • ERR_remove_state() calls removed (no-op since OpenSSL 1.1)

I haven't been able to run the SecurityTest/SecurityFromBufferTest locally — if there are still test timeouts, happy to iterate.

@loqs

loqs commented Aug 28, 2026

Copy link
Copy Markdown

Thank you for working on this. There are still timeouts which I was able to fix with:

--- a/lib/cpp/test/SecurityFromBufferTest.cpp
+++ b/lib/cpp/test/SecurityFromBufferTest.cpp
@@ -229,7 +229,7 @@ BOOST_AUTO_TEST_CASE(ssl_security_matrix) {
           continue;
         }
 
-#ifdef OPENSSL_NO_SSL3
+#if defined(OPENSSL_NO_SSL3) || OPENSSL_VERSION_NUMBER >= 0x40000000L
         if (si == 2 || ci == 2) {
           // Skip all SSLv3 cases - protocol not supported
           continue;
diff --git a/lib/cpp/test/SecurityTest.cpp b/lib/cpp/test/SecurityTest.cpp
index 86640bd68..b133ef0f8 100644
--- a/lib/cpp/test/SecurityTest.cpp
+++ b/lib/cpp/test/SecurityTest.cpp
@@ -357,7 +357,7 @@ BOOST_AUTO_TEST_CASE(ssl_security_matrix)
                     continue;
                 }
 
-#ifdef OPENSSL_NO_SSL3
+#if defined(OPENSSL_NO_SSL3) || OPENSSL_VERSION_NUMBER >= 0x40000000L
                 if (si == 2 || ci == 2)
                 {
                     // Skip all SSLv3 cases - protocol not supported

All tests then pass for C and C++ however I believe that is due to lack of coverage in testtransportsslsocket.c compared to SecurityTest.cpp for SSLv3/TLSv1_0/TLSv1_1. I think the C code needs SSL_CTX_set_min_proto_version() / SSL_CTX_set_max_proto_version() to match the C++ code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c_glib c++ Pull requests that update C++ code rebase needed rebase needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants