Skip to content

Commit c98c633

Browse files
Jaipaul Cheernamkraj
authored andcommitted
thrift: fix build with OpenSSL 4.0
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>
1 parent c4a2877 commit c98c633

2 files changed

Lines changed: 114 additions & 0 deletions

File tree

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2+
From: Jaipaul Cheernam <jaipaul.cheernam@est.tech>
3+
Date: Thu, 27 Aug 2026 11:00:00 +0000
4+
Subject: [PATCH] Fix build with OpenSSL 4.0
5+
6+
OpenSSL 4.0 removes SSLv3_method(), per-version TLS method functions,
7+
ERR_remove_state(), ASN1_STRING_data(), and returns const pointers
8+
from X509 accessor functions.
9+
10+
C++ (TSSLSocket.cpp):
11+
- Guard SSLv3 and TLS version methods with version check
12+
- Replace ASN1_STRING_data with ASN1_STRING_get0_data
13+
- Add const qualifiers for X509_NAME, X509_NAME_ENTRY, ASN1_STRING
14+
15+
C (thrift_ssl_socket.c):
16+
- Remove ERR_remove_state() calls (no-op since OpenSSL 1.1)
17+
- Guard SSLv3 and TLS version methods with version check
18+
19+
Upstream-Status: Submitted [https://github.com/apache/thrift/pull/3752]
20+
21+
Signed-off-by: Jaipaul Cheernam <jaipaul.cheernam@est.tech>
22+
---
23+
diff --git a/lib/cpp/src/thrift/transport/TSSLSocket.cpp b/lib/cpp/src/thrift/transport/TSSLSocket.cpp
24+
--- a/lib/cpp/src/thrift/transport/TSSLSocket.cpp 2026-08-27 11:26:40.242005669 +0000
25+
+++ b/lib/cpp/src/thrift/transport/TSSLSocket.cpp 2026-08-27 11:26:40.263005736 +0000
26+
@@ -182,16 +182,18 @@
27+
SSLContext::SSLContext(const SSLProtocol& protocol) {
28+
if (protocol == SSLTLS) {
29+
ctx_ = SSL_CTX_new(SSLv23_method());
30+
-#ifndef OPENSSL_NO_SSL3
31+
+#if !defined(OPENSSL_NO_SSL3) && OPENSSL_VERSION_NUMBER < 0x40000000L
32+
} else if (protocol == SSLv3) {
33+
ctx_ = SSL_CTX_new(SSLv3_method());
34+
#endif
35+
+#if OPENSSL_VERSION_NUMBER < 0x40000000L
36+
} else if (protocol == TLSv1_0) {
37+
ctx_ = SSL_CTX_new(TLSv1_method());
38+
} else if (protocol == TLSv1_1) {
39+
ctx_ = SSL_CTX_new(TLSv1_1_method());
40+
} else if (protocol == TLSv1_2) {
41+
ctx_ = SSL_CTX_new(TLSv1_2_method());
42+
+#endif
43+
} else {
44+
/// UNKNOWN PROTOCOL!
45+
throw TSSLException("SSL_CTX_new: Unknown protocol");
46+
@@ -770,7 +772,7 @@
47+
if (name == nullptr) {
48+
continue;
49+
}
50+
- char* data = (char*)ASN1_STRING_data(name->d.ia5);
51+
+ const char* data = (const char*)ASN1_STRING_get0_data(name->d.ia5);
52+
int length = ASN1_STRING_length(name->d.ia5);
53+
switch (name->type) {
54+
case GEN_DNS:
55+
@@ -796,19 +798,19 @@
56+
}
57+
58+
// extract commonName
59+
- X509_NAME* name = X509_get_subject_name(cert);
60+
+ const X509_NAME* name = X509_get_subject_name(cert);
61+
if (name != nullptr) {
62+
- X509_NAME_ENTRY* entry;
63+
+ const X509_NAME_ENTRY* entry;
64+
unsigned char* utf8;
65+
int last = -1;
66+
while (decision == AccessManager::SKIP) {
67+
- last = X509_NAME_get_index_by_NID(name, NID_commonName, last);
68+
+ last = X509_NAME_get_index_by_NID((X509_NAME *)name, NID_commonName, last);
69+
if (last == -1)
70+
break;
71+
entry = X509_NAME_get_entry(name, last);
72+
if (entry == nullptr)
73+
continue;
74+
- ASN1_STRING* common = X509_NAME_ENTRY_get_data(entry);
75+
+ const ASN1_STRING* common = X509_NAME_ENTRY_get_data(entry);
76+
int size = ASN1_STRING_to_UTF8(&utf8, common);
77+
if (host.empty()) {
78+
host = (server() ? getPeerHost() : getHost());
79+
diff --git a/lib/c_glib/src/thrift/c_glib/transport/thrift_ssl_socket.c b/lib/c_glib/src/thrift/c_glib/transport/thrift_ssl_socket.c
80+
--- a/lib/c_glib/src/thrift/c_glib/transport/thrift_ssl_socket.c 2026-08-27 11:26:40.245005679 +0000
81+
+++ b/lib/c_glib/src/thrift/c_glib/transport/thrift_ssl_socket.c 2026-08-27 11:26:52.923045957 +0000
82+
@@ -285,7 +285,6 @@
83+
SSL_shutdown(ssl_socket->ssl);
84+
SSL_free(ssl_socket->ssl);
85+
ssl_socket->ssl = NULL;
86+
- ERR_remove_state(0);
87+
}
88+
return thrift_socket_close(transport, error);
89+
}
90+
@@ -710,7 +709,6 @@
91+
ERR_free_strings();
92+
EVP_cleanup();
93+
CRYPTO_cleanup_all_ex_data();
94+
- ERR_remove_state(0);
95+
}
96+
97+
98+
@@ -835,6 +833,7 @@
99+
case SSLTLS:
100+
context = SSL_CTX_new(SSLv23_method());
101+
break;
102+
+#if OPENSSL_VERSION_NUMBER < 0x40000000L
103+
#ifndef OPENSSL_NO_SSL3
104+
case SSLv3:
105+
context = SSL_CTX_new(SSLv3_method());
106+
@@ -849,6 +848,7 @@
107+
case TLSv1_2:
108+
context = SSL_CTX_new(TLSv1_2_method());
109+
break;
110+
+#endif /* OPENSSL_VERSION_NUMBER < 0x40000000L */
111+
default:
112+
g_set_error (error, THRIFT_TRANSPORT_ERROR,
113+
THRIFT_SSL_SOCKET_ERROR_CIPHER_NOT_AVAILABLE,

meta-oe/recipes-connectivity/thrift/thrift_0.24.0.bb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ DEPENDS = "thrift-native boost flex-native bison-native openssl zlib"
1010

1111
SRC_URI = "https://downloads.apache.org/${BPN}/${PV}/${BP}.tar.gz \
1212
file://0001-DefineInstallationPaths.cmake-Define-libdir-in-terms.patch \
13+
file://0001-TSSLSocket-fix-build-with-OpenSSL-4.0.patch \
1314
"
1415
SRC_URI[sha256sum] = "e0fa5839a4c5c1d631b0931cf2c554ebbfa4e2fee3a9fb3ffd4f82ce4396c6e4"
1516

0 commit comments

Comments
 (0)