Skip to content

Commit b1144e6

Browse files
committed
proftpd: allow build with OpenSSL 4.0.0
1 parent 23dcda6 commit b1144e6

File tree

1 file changed

+198
-0
lines changed

1 file changed

+198
-0
lines changed
Lines changed: 198 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,198 @@
1+
From 4c92e9b9bd4612b6268beba36b4009b94e702ada Mon Sep 17 00:00:00 2001
2+
From: Rudi Heitbaum <rudi@heitbaum.com>
3+
Date: Sat, 21 Mar 2026 07:26:07 +0000
4+
Subject: [PATCH] mod_tls: allow build with OpenSSL 4.x
5+
MIME-Version: 1.0
6+
Content-Type: text/plain; charset=UTF-8
7+
Content-Transfer-Encoding: 8bit
8+
9+
ASN1_STRING are now opaque types — the internal data and length fields are
10+
no longer directly accessible. Use the accessor API instead. Accessors
11+
have been available since OpenSSL 1.1.0
12+
13+
Signatures of numerous API functions, including those that are related
14+
to X509 processing, are changed to include const qualifiers for argument
15+
and return types, where suitable. Add const qualifer to variables.
16+
17+
Signed-off-by: Rudi Heitbaum <rudi@heitbaum.com>
18+
---
19+
contrib/mod_tls.c | 46 +++++++++++++++++++++++-----------------------
20+
1 file changed, 23 insertions(+), 23 deletions(-)
21+
22+
diff --git a/contrib/mod_tls.c b/contrib/mod_tls.c
23+
index 435240025..cacf795e2 100644
24+
--- a/contrib/mod_tls.c
25+
+++ b/contrib/mod_tls.c
26+
@@ -799,7 +799,7 @@ static void tls_setup_notes(pool *p, SSL *ssl);
27+
static int tls_verify_cb(int, X509_STORE_CTX *);
28+
static int tls_verify_crl(int, X509_STORE_CTX *);
29+
static int tls_verify_ocsp(int, X509_STORE_CTX *);
30+
-static char *tls_x509_name_oneline(X509_NAME *);
31+
+static char *tls_x509_name_oneline(const X509_NAME *);
32+
33+
static int tls_readmore(int);
34+
static int tls_writemore(int);
35+
@@ -2759,9 +2759,9 @@ static int tls_cert_match_ip_san(pool *p, X509 *cert, const char *ipstr) {
36+
37+
static char *tls_get_cert_cn(pool *p, X509 *cert) {
38+
int idx = -1;
39+
- X509_NAME *subj_name = NULL;
40+
- X509_NAME_ENTRY *cn_entry = NULL;
41+
- ASN1_STRING *cn_asn1 = NULL;
42+
+ const X509_NAME *subj_name = NULL;
43+
+ const X509_NAME_ENTRY *cn_entry = NULL;
44+
+ const ASN1_STRING *cn_asn1 = NULL;
45+
char *cn_str = NULL;
46+
size_t cn_len = 0;
47+
48+
@@ -6185,7 +6185,7 @@ static int ocsp_add_cached_response(pool *p, const char *fingerprint,
49+
return res;
50+
}
51+
52+
-static int tls_feature_cmp(ASN1_STRING *str, void *feat_data,
53+
+static int tls_feature_cmp(const ASN1_STRING *str, void *feat_data,
54+
size_t feat_datasz) {
55+
int is_feat = FALSE, res;
56+
ASN1_STRING *feat;
57+
@@ -6229,8 +6229,8 @@ static int tls_cert_must_staple(X509 *cert, int *v2) {
58+
59+
for (i = 0; i < ext_count; i++) {
60+
char buf[1024];
61+
- X509_EXTENSION *ext;
62+
- ASN1_OBJECT *obj;
63+
+ const X509_EXTENSION *ext;
64+
+ const ASN1_OBJECT *obj;
65+
66+
#if (OPENSSL_VERSION_NUMBER >= 0x10100000L && !defined(HAVE_LIBRESSL)) || \
67+
(defined(HAVE_LIBRESSL) && LIBRESSL_VERSION_NUMBER >= 0x3050000L)
68+
@@ -6246,7 +6246,7 @@ static int tls_cert_must_staple(X509 *cert, int *v2) {
69+
/* Double-check that the OID is that of the "TLS Feature" extension. */
70+
if (strcmp(buf, TLS_X509V3_TLS_FEAT_OID_TEXT) == 0) {
71+
char status_request[] = TLS_X509V3_TLS_FEAT_STATUS_REQUEST;
72+
- ASN1_OCTET_STRING *value;
73+
+ const ASN1_OCTET_STRING *value;
74+
75+
#if (OPENSSL_VERSION_NUMBER >= 0x10100000L && !defined(HAVE_LIBRESSL)) || \
76+
(defined(HAVE_LIBRESSL) && LIBRESSL_VERSION_NUMBER >= 0x3050000L)
77+
@@ -9443,14 +9443,14 @@ static int tls_cert_to_user(const char *user_name, const char *field_name) {
78+
}
79+
80+
if (strcmp(field_name, "CommonName") == 0) {
81+
- X509_NAME *name;
82+
+ const X509_NAME *name;
83+
int pos = -1;
84+
85+
name = X509_get_subject_name(client_cert);
86+
87+
while (TRUE) {
88+
- X509_NAME_ENTRY *entry;
89+
- ASN1_STRING *data;
90+
+ const X509_NAME_ENTRY *entry;
91+
+ const ASN1_STRING *data;
92+
int data_len;
93+
const unsigned char *data_str = NULL;
94+
95+
@@ -9561,8 +9561,8 @@ static int tls_cert_to_user(const char *user_name, const char *field_name) {
96+
register int i;
97+
98+
for (i = 0; i < nexts; i++) {
99+
- X509_EXTENSION *ext = NULL;
100+
- ASN1_OBJECT *asn_object = NULL;
101+
+ const X509_EXTENSION *ext = NULL;
102+
+ const ASN1_OBJECT *asn_object = NULL;
103+
char oid[PR_TUNABLE_PATH_MAX];
104+
105+
pr_signals_handle();
106+
@@ -9574,7 +9574,7 @@ static int tls_cert_to_user(const char *user_name, const char *field_name) {
107+
memset(oid, '\0', sizeof(oid));
108+
if (OBJ_obj2txt(oid, sizeof(oid)-1, asn_object, 1) > 0) {
109+
if (strcmp(oid, field_name) == 0) {
110+
- ASN1_OCTET_STRING *asn_data = NULL;
111+
+ const ASN1_OCTET_STRING *asn_data = NULL;
112+
const unsigned char *asn_datastr = NULL;
113+
int asn_datalen;
114+
115+
@@ -9871,7 +9871,7 @@ static void tls_setup_cert_ext_environ(const char *env_prefix, X509 *cert) {
116+
* email Email NID_pkcs9_emailAddress
117+
*/
118+
119+
-static void tls_setup_cert_dn_environ(const char *env_prefix, X509_NAME *name) {
120+
+static void tls_setup_cert_dn_environ(const char *env_prefix, const X509_NAME *name) {
121+
register int i;
122+
int nentries;
123+
char *k, *v;
124+
@@ -9883,7 +9883,7 @@ static void tls_setup_cert_dn_environ(const char *env_prefix, X509_NAME *name) {
125+
#endif /* OpenSSL-1.1.x and later */
126+
127+
for (i = 0; i < nentries; i++) {
128+
- X509_NAME_ENTRY *entry;
129+
+ const X509_NAME_ENTRY *entry;
130+
const unsigned char *entry_data;
131+
int nid, entry_len;
132+
133+
@@ -10000,7 +10000,7 @@ static void tls_setup_cert_environ(pool *p, const char *env_prefix,
134+
char buf[80] = {'\0'};
135+
ASN1_INTEGER *serial = X509_get_serialNumber(cert);
136+
const X509_ALGOR *algo = NULL;
137+
- X509_PUBKEY *pubkey = NULL;
138+
+ const X509_PUBKEY *pubkey = NULL;
139+
140+
memset(buf, '\0', sizeof(buf));
141+
pr_snprintf(buf, sizeof(buf) - 1, "%lu", X509_get_version(cert) + 1);
142+
@@ -10010,7 +10010,7 @@ static void tls_setup_cert_environ(pool *p, const char *env_prefix,
143+
v = pstrdup(p, buf);
144+
pr_env_set(p, k, v);
145+
146+
- if (serial->length < 4) {
147+
+ if (ASN1_STRING_length(serial) < 4) {
148+
memset(buf, '\0', sizeof(buf));
149+
pr_snprintf(buf, sizeof(buf) - 1, "%lu", ASN1_INTEGER_get(serial));
150+
buf[sizeof(buf)-1] = '\0';
151+
@@ -10290,7 +10290,7 @@ static void tls_setup_notes(pool *p, SSL *ssl) {
152+
client_cert = SSL_get_peer_certificate(ssl);
153+
if (client_cert != NULL) {
154+
const X509_ALGOR *algo = NULL;
155+
- X509_PUBKEY *pubkey = NULL;
156+
+ const X509_PUBKEY *pubkey = NULL;
157+
BIO *bio = NULL;
158+
char *data = NULL;
159+
long datalen = 0;
160+
@@ -10446,7 +10446,7 @@ static int tls_verify_cb(int ok, X509_STORE_CTX *ctx) {
161+
162+
static int tls_verify_crl(int ok, X509_STORE_CTX *ctx) {
163+
register int i = 0;
164+
- X509_NAME *subject = NULL, *issuer = NULL;
165+
+ const X509_NAME *subject = NULL, *issuer = NULL;
166+
X509 *xs = NULL;
167+
STACK_OF(X509_CRL) *crls = NULL;
168+
int res, verify_error;
169+
@@ -10624,7 +10624,7 @@ static int tls_verify_ocsp_url(X509_STORE_CTX *ctx, X509 *cert,
170+
const char *url) {
171+
BIO *conn;
172+
X509 *issuing_cert = NULL;
173+
- X509_NAME *subj = NULL;
174+
+ const X509_NAME *subj = NULL;
175+
X509_STORE *store = NULL;
176+
const char *subj_name;
177+
char *host = NULL, *port = NULL, *uri = NULL;
178+
@@ -11043,7 +11043,7 @@ static int tls_verify_ocsp(int ok, X509_STORE_CTX *ctx) {
179+
}
180+
181+
*((char **) push_array(ocsp_urls)) = pstrdup(tmp_pool,
182+
- (char *) desc->location->d.uniformResourceIdentifier->data);
183+
+ (char *) ASN1_STRING_get0_data(desc->location->d.uniformResourceIdentifier));
184+
}
185+
}
186+
187+
@@ -11111,7 +11111,7 @@ static ssize_t tls_write(SSL *ssl, const void *buf, size_t len) {
188+
return count;
189+
}
190+
191+
-static char *tls_x509_name_oneline(X509_NAME *x509_name) {
192+
+static char *tls_x509_name_oneline(const X509_NAME *x509_name) {
193+
static char buf[1024] = {'\0'};
194+
195+
/* If we are using OpenSSL 0.9.6 or newer, we want to use
196+
--
197+
2.53.0
198+

0 commit comments

Comments
 (0)