Skip to content

Commit e340b81

Browse files
committed
Fix OpenSSL 4.0 compatibility and test that in CI.
CI: Update to test OpenSSL 4.0.0 explicitly. CI: No longer disable deprecated-declaration warnings for OpenSSL 3.4 -Werror build. * modules/ssl/ssl_engine_kernel.c (ssl_hook_UserCheck): Change name to const X509_NAME *. (ssl_callback_proxy_cert): Change ca_name, issuer, and ca_issuer to const X509_NAME *. * modules/ssl/ssl_engine_log.c (ssl_log_cert_error): Change cert parameter to const X509 *. Use X509_get0_serialNumber, X509_get0_notBefore, and X509_get0_notAfter instead of non-const variants. (ssl_log_xerror, ssl_log_cxerror, ssl_log_rxerror): Change cert parameter to const X509 *. * modules/ssl/ssl_engine_vars.c (ssl_var_lookup_ssl_cert_dn): Change xsname parameter to const X509_NAME *. (ssl_var_lookup_ssl_cert_dn_oneline): Change xsname parameter to const X509_NAME *. (ssl_var_lookup_ssl_cert): Change xsname to const X509_NAME *. (ssl_var_lookup_ssl_cert_rfc4523_cea): Change issuer to const X509_NAME *. * modules/ssl/ssl_private.h (ssl_log_xerror, ssl_log_cxerror, ssl_log_rxerror): Update declarations to use const X509 *. * modules/ssl/ssl_util_ssl.c (modssl_X509_NAME_to_string): Change dn parameter to const X509_NAME *. (getIDs): Change subj to const X509_NAME *. * modules/ssl/ssl_util_ssl.h (modssl_X509_NAME_to_string): Update declaration to use const X509_NAME *. * support/ab.c (ssl_print_cert_info): Change dn to const X509_NAME *. mod_ssl: use ASN1_STRING accessor API in dump_extn_value: * modules/ssl/ssl_engine_vars.c (dump_extn_value): Use ASN1_STRING_get0_data() and ASN1_STRING_length() rather than directly dereferencing the ASN1_OCTET_STRING structure, which is opaque in OpenSSL 4.0. * modules/ssl/ssl_private.h: Add compat macros for ASN1_STRING_get0_data and ASN1_STRING_length for pre-1.1 API. mod_ssl: constify ASN1_TIME pointers, use X509_get0_not{Before,After}: * modules/ssl/ssl_engine_vars.c (ssl_var_lookup_ssl_cert_valid, ssl_var_lookup_ssl_cert_remain): Constify ASN1_TIME * parameter. (ssl_var_lookup_ssl_cert): Use X509_get0_notBefore() and X509_get0_notAfter() which return const pointers. (ssl_var_lookup_ssl_cert_remain): Use ASN1_TIME_check() directly rather than INVALID_ASN1_TIME macro which dereferences the ASN1_TIME structure. (dump_extn_value): Constify ASN1_OCTET_STRING * parameter. * modules/ssl/ssl_private.h: Add compat macros for X509_get0_before and X509_get0_after for pre-1.1 API. mod_ssl: constify X509_NAME_ENTRY and X509_EXTENSION pointers: * modules/ssl/ssl_engine_vars.c (ssl_var_lookup_ssl_cert_dn, extract_dn): Constify X509_NAME_ENTRY * variables, constify X509_NAME * parameter of extract_dn, drop unnecessary casts on X509_NAME_ENTRY_get_object() calls. (ssl_ext_list): Use MODSSL_X509_EXT_CONST for X509_EXTENSION * since X509_EXTENSION accessors are only constified in OpenSSL 4. * modules/ssl/ssl_util_ssl.c, modules/ssl/ssl_util_ssl.h (modssl_X509_NAME_ENTRY_to_string): Constify X509_NAME_ENTRY * parameter. * modules/ssl/ssl_private.h: Add MODSSL_X509_EXT_CONST, defined as const for OpenSSL 4+ and empty otherwise. * modules/ssl/ssl_util_ssl.c (asn1_string_convert): Constify ASN1_STRING * argument. * modules/ssl/ssl_engine_ocsp.c (extract_responder_uri): Use modssl_ASN1_STRING_convert instead of directly accessing ASN1_STRING data pointer. * modules/ssl/ssl_util_ssl.c (modssl_ASN1_STRING_convert): Rename from asn1_string_convert and export function. (asn1_string_to_utf8): Update to use modssl_ASN1_STRING_convert. (modssl_X509_NAME_ENTRY_to_string): Update to use modssl_ASN1_STRING_convert. * modules/ssl/ssl_util_ssl.h (modssl_ASN1_STRING_convert): Declare new function. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Github: closes #609 git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1933586 13f79535-47bb-0310-9956-ffa450edef68
1 parent 1eca929 commit e340b81

9 files changed

Lines changed: 67 additions & 52 deletions

File tree

.github/workflows/linux.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ jobs:
287287
# -------------------------------------------------------------------------
288288
- name: OpenSSL 3.4 -Werror
289289
config: --enable-mods-shared=most --enable-maintainer-mode --disable-md --disable-http2 --disable-ldap --disable-crypto
290-
notest-cflags: -Werror -O2 -Wno-deprecated-declarations
290+
notest-cflags: -Werror -O2
291291
env: |
292292
TEST_OPENSSL3=3.4.4
293293
APR_VERSION=1.7.6
@@ -316,12 +316,11 @@ jobs:
316316
APU_CONFIG="--without-crypto"
317317
pkgs: subversion
318318
# -------------------------------------------------------------------------
319-
- name: OpenSSL ECH branch
319+
- name: OpenSSL 4.0
320320
config: --enable-mods-shared=most --enable-maintainer-mode --disable-md --disable-http2 --disable-ldap --disable-crypto
321321
notest-cflags: -Werror -O2
322322
env: |
323-
TEST_OPENSSL3=ech2
324-
TEST_OPENSSL3_BRANCH=feature/ech
323+
TEST_OPENSSL3=4.0.0
325324
OPENSSL_CONFIG=no-engine
326325
APR_VERSION=1.7.6
327326
APU_VERSION=1.6.3

modules/ssl/ssl_engine_kernel.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1263,7 +1263,7 @@ int ssl_hook_UserCheck(request_rec *r)
12631263
}
12641264

12651265
if (!sslconn->client_dn) {
1266-
X509_NAME *name = X509_get_subject_name(sslconn->client_cert);
1266+
const X509_NAME *name = X509_get_subject_name(sslconn->client_cert);
12671267
char *cp = X509_NAME_oneline(name, NULL, 0);
12681268
sslconn->client_dn = apr_pstrdup(r->connection->pool, cp);
12691269
OPENSSL_free(cp);
@@ -1817,7 +1817,7 @@ int ssl_callback_proxy_cert(SSL *ssl, X509 **x509, EVP_PKEY **pkey)
18171817
server_rec *s = mySrvFromConn(c);
18181818
SSLSrvConfigRec *sc = mySrvConfig(s);
18191819
SSLDirConfigRec *dc = myDirConfigFromConn(c);
1820-
X509_NAME *ca_name, *issuer, *ca_issuer;
1820+
const X509_NAME *ca_name, *issuer, *ca_issuer;
18211821
X509_INFO *info;
18221822
X509 *ca_cert;
18231823
STACK_OF(X509_NAME) *ca_list;

modules/ssl/ssl_engine_log.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ void ssl_log_ssl_error(const char *file, int line, int level, server_rec *s)
126126
static void ssl_log_cert_error(const char *file, int line, int level,
127127
apr_status_t rv, const server_rec *s,
128128
const conn_rec *c, const request_rec *r,
129-
apr_pool_t *p, X509 *cert, const char *format,
129+
apr_pool_t *p, const X509 *cert, const char *format,
130130
va_list ap)
131131
{
132132
char buf[HUGE_STRING_LEN];
@@ -167,14 +167,14 @@ static void ssl_log_cert_error(const char *file, int line, int level,
167167
}
168168

169169
BIO_puts(bio, " / serial: ");
170-
if (i2a_ASN1_INTEGER(bio, X509_get_serialNumber(cert)) == -1)
170+
if (i2a_ASN1_INTEGER(bio, X509_get0_serialNumber(cert)) == -1)
171171
BIO_puts(bio, "(ERROR)");
172172

173173
BIO_puts(bio, " / notbefore: ");
174-
ASN1_TIME_print(bio, X509_get_notBefore(cert));
174+
ASN1_TIME_print(bio, X509_get0_notBefore(cert));
175175

176176
BIO_puts(bio, " / notafter: ");
177-
ASN1_TIME_print(bio, X509_get_notAfter(cert));
177+
ASN1_TIME_print(bio, X509_get0_notAfter(cert));
178178

179179
BIO_puts(bio, "]");
180180

@@ -212,7 +212,7 @@ static void ssl_log_cert_error(const char *file, int line, int level,
212212
* in the other cases we use the connection and request pool, respectively).
213213
*/
214214
void ssl_log_xerror(const char *file, int line, int level, apr_status_t rv,
215-
apr_pool_t *ptemp, server_rec *s, X509 *cert,
215+
apr_pool_t *ptemp, server_rec *s, const X509 *cert,
216216
const char *fmt, ...)
217217
{
218218
if (APLOG_IS_LEVEL(s,level)) {
@@ -225,7 +225,7 @@ void ssl_log_xerror(const char *file, int line, int level, apr_status_t rv,
225225
}
226226

227227
void ssl_log_cxerror(const char *file, int line, int level, apr_status_t rv,
228-
conn_rec *c, X509 *cert, const char *fmt, ...)
228+
conn_rec *c, const X509 *cert, const char *fmt, ...)
229229
{
230230
if (APLOG_IS_LEVEL(mySrvFromConn(c),level)) {
231231
va_list ap;
@@ -237,7 +237,7 @@ void ssl_log_cxerror(const char *file, int line, int level, apr_status_t rv,
237237
}
238238

239239
void ssl_log_rxerror(const char *file, int line, int level, apr_status_t rv,
240-
request_rec *r, X509 *cert, const char *fmt, ...)
240+
request_rec *r, const X509 *cert, const char *fmt, ...)
241241
{
242242
if (APLOG_R_IS_LEVEL(r,level)) {
243243
va_list ap;

modules/ssl/ssl_engine_ocsp.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ static const char *extract_responder_uri(X509 *cert, apr_pool_t *pool)
3838
/* Name found in extension, and is a URI: */
3939
if (OBJ_obj2nid(value->method) == NID_ad_OCSP
4040
&& value->location->type == GEN_URI) {
41-
result = apr_pstrdup(pool,
42-
(char *)value->location->d.uniformResourceIdentifier->data);
41+
const ASN1_STRING *uri = value->location->d.uniformResourceIdentifier;
42+
result = modssl_ASN1_STRING_convert(pool, uri, 0);
4343
}
4444
}
4545

modules/ssl/ssl_engine_vars.c

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@
4141

4242
static const char *ssl_var_lookup_ssl(apr_pool_t *p, const SSLConnRec *sslconn, request_rec *r, const char *var);
4343
static const char *ssl_var_lookup_ssl_cert(apr_pool_t *p, request_rec *r, X509 *xs, const char *var);
44-
static const char *ssl_var_lookup_ssl_cert_dn(apr_pool_t *p, X509_NAME *xsname, const char *var);
44+
static const char *ssl_var_lookup_ssl_cert_dn(apr_pool_t *p, const X509_NAME *xsname, const char *var);
4545
static const char *ssl_var_lookup_ssl_cert_san(apr_pool_t *p, X509 *xs, const char *var);
46-
static const char *ssl_var_lookup_ssl_cert_valid(apr_pool_t *p, ASN1_TIME *tm);
47-
static const char *ssl_var_lookup_ssl_cert_remain(apr_pool_t *p, ASN1_TIME *tm);
46+
static const char *ssl_var_lookup_ssl_cert_valid(apr_pool_t *p, const ASN1_TIME *tm);
47+
static const char *ssl_var_lookup_ssl_cert_remain(apr_pool_t *p, const ASN1_TIME *tm);
4848
static const char *ssl_var_lookup_ssl_cert_serial(apr_pool_t *p, X509 *xs);
4949
static const char *ssl_var_lookup_ssl_cert_chain(apr_pool_t *p, STACK_OF(X509) *sk, const char *var, int pem);
5050
static const char *ssl_var_lookup_ssl_cert_rfc4523_cea(apr_pool_t *p, SSL *ssl);
@@ -598,7 +598,7 @@ static const char *ssl_var_lookup_ssl(apr_pool_t *p, const SSLConnRec *sslconn,
598598
}
599599

600600
static const char *ssl_var_lookup_ssl_cert_dn_oneline(apr_pool_t *p, request_rec *r,
601-
X509_NAME *xsname)
601+
const X509_NAME *xsname)
602602
{
603603
char *result = NULL;
604604
SSLDirConfigRec *dc;
@@ -629,7 +629,7 @@ static const char *ssl_var_lookup_ssl_cert(apr_pool_t *p, request_rec *r, X509 *
629629
const char *var)
630630
{
631631
const char *result;
632-
X509_NAME *xsname;
632+
const X509_NAME *xsname;
633633
int nid;
634634

635635
result = NULL;
@@ -641,13 +641,13 @@ static const char *ssl_var_lookup_ssl_cert(apr_pool_t *p, request_rec *r, X509 *
641641
result = ssl_var_lookup_ssl_cert_serial(p, xs);
642642
}
643643
else if (strcEQ(var, "V_START")) {
644-
result = ssl_var_lookup_ssl_cert_valid(p, X509_get_notBefore(xs));
644+
result = ssl_var_lookup_ssl_cert_valid(p, X509_get0_notBefore(xs));
645645
}
646646
else if (strcEQ(var, "V_END")) {
647-
result = ssl_var_lookup_ssl_cert_valid(p, X509_get_notAfter(xs));
647+
result = ssl_var_lookup_ssl_cert_valid(p, X509_get0_notAfter(xs));
648648
}
649649
else if (strcEQ(var, "V_REMAIN")) {
650-
result = ssl_var_lookup_ssl_cert_remain(p, X509_get_notAfter(xs));
650+
result = ssl_var_lookup_ssl_cert_remain(p, X509_get0_notAfter(xs));
651651
}
652652
else if (*var && strcEQ(var+1, "_DN")) {
653653
if (*var == 'S')
@@ -727,12 +727,12 @@ static const struct {
727727
{ NULL, 0, 0 }
728728
};
729729

730-
static const char *ssl_var_lookup_ssl_cert_dn(apr_pool_t *p, X509_NAME *xsname,
731-
const char *var)
730+
static const char *ssl_var_lookup_ssl_cert_dn(apr_pool_t *p, const X509_NAME *xsname,
731+
const char *var)
732732
{
733733
const char *ptr;
734734
const char *result;
735-
X509_NAME_ENTRY *xsne;
735+
const X509_NAME_ENTRY *xsne;
736736
int i, j, n, idx = 0, raw = 0;
737737
apr_size_t varlen;
738738

@@ -759,7 +759,7 @@ static const char *ssl_var_lookup_ssl_cert_dn(apr_pool_t *p, X509_NAME *xsname,
759759
for (j = 0; j < X509_NAME_entry_count(xsname); j++) {
760760
xsne = X509_NAME_get_entry(xsname, j);
761761

762-
n =OBJ_obj2nid((ASN1_OBJECT *)X509_NAME_ENTRY_get_object(xsne));
762+
n = OBJ_obj2nid(X509_NAME_ENTRY_get_object(xsne));
763763

764764
if (n == ssl_var_lookup_ssl_cert_dn_rec[i].nid && idx-- == 0) {
765765
result = modssl_X509_NAME_ENTRY_to_string(p, xsne, raw);
@@ -816,7 +816,7 @@ static const char *ssl_var_lookup_ssl_cert_san(apr_pool_t *p, X509 *xs, const ch
816816
return NULL;
817817
}
818818

819-
static const char *ssl_var_lookup_ssl_cert_valid(apr_pool_t *p, ASN1_TIME *tm)
819+
static const char *ssl_var_lookup_ssl_cert_valid(apr_pool_t *p, const ASN1_TIME *tm)
820820
{
821821
BIO* bio;
822822

@@ -837,12 +837,12 @@ static const char *ssl_var_lookup_ssl_cert_valid(apr_pool_t *p, ASN1_TIME *tm)
837837

838838
/* Return a string giving the number of days remaining until 'tm', or
839839
* "0" if this can't be determined. */
840-
static const char *ssl_var_lookup_ssl_cert_remain(apr_pool_t *p, ASN1_TIME *tm)
840+
static const char *ssl_var_lookup_ssl_cert_remain(apr_pool_t *p, const ASN1_TIME *tm)
841841
{
842842
#if OPENSSL_VERSION_NUMBER >= 0x10101000L && !defined(LIBRESSL_VERSION_NUMBER)
843843
int diff;
844844

845-
if (INVALID_ASN1_TIME(tm) || ASN1_TIME_diff(&diff, NULL, NULL, tm) != 1) {
845+
if (ASN1_TIME_check(tm) != 1 || ASN1_TIME_diff(&diff, NULL, NULL, tm) != 1) {
846846
return "0";
847847
}
848848
#else
@@ -929,7 +929,7 @@ static const char *ssl_var_lookup_ssl_cert_rfc4523_cea(apr_pool_t *p, SSL *ssl)
929929

930930
serialNumber = X509_get_serialNumber(xs);
931931
if (serialNumber) {
932-
X509_NAME *issuer = X509_get_issuer_name(xs);
932+
const X509_NAME *issuer = X509_get_issuer_name(xs);
933933
if (issuer) {
934934
BIGNUM *bn = ASN1_INTEGER_to_BN(serialNumber, NULL);
935935
if((decimal = BN_bn2dec(bn)) == NULL) {
@@ -1112,9 +1112,9 @@ static const char *ssl_var_lookup_ssl_version(const char *var)
11121112
/* Add each RDN in 'xn' to the table 't' where the NID is present in
11131113
* 'nids', using key prefix 'pfx'. */
11141114
static void extract_dn(apr_table_t *t, apr_hash_t *nids, const char *pfx,
1115-
X509_NAME *xn, apr_pool_t *p)
1115+
const X509_NAME *xn, apr_pool_t *p)
11161116
{
1117-
X509_NAME_ENTRY *xsne;
1117+
const X509_NAME_ENTRY *xsne;
11181118
apr_hash_t *count;
11191119
int i, nid;
11201120

@@ -1129,7 +1129,7 @@ static void extract_dn(apr_table_t *t, apr_hash_t *nids, const char *pfx,
11291129

11301130
/* Retrieve the nid, and check whether this is one of the nids
11311131
* which are to be extracted. */
1132-
nid = OBJ_obj2nid((ASN1_OBJECT *)X509_NAME_ENTRY_get_object(xsne));
1132+
nid = OBJ_obj2nid(X509_NAME_ENTRY_get_object(xsne));
11331133

11341134
tag = apr_hash_get(nids, &nid, sizeof nid);
11351135
if (tag) {
@@ -1242,19 +1242,19 @@ void modssl_var_extract_san_entries(apr_table_t *t, SSL *ssl, apr_pool_t *p)
12421242
* parse the extension type as a primitive string. This will fail for
12431243
* any structured extension type per the docs. Returns non-zero on
12441244
* success and writes the string to the given bio. */
1245-
static int dump_extn_value(BIO *bio, ASN1_OCTET_STRING *str)
1245+
static int dump_extn_value(BIO *bio, const ASN1_OCTET_STRING *str)
12461246
{
1247-
const unsigned char *pp = str->data;
1247+
const unsigned char *pp = ASN1_STRING_get0_data(str);
12481248
ASN1_STRING *ret = ASN1_STRING_new();
12491249
int rv = 0;
12501250

1251-
if(!ret) {
1252-
return rv;
1251+
if (!ret) {
1252+
return rv;
12531253
}
12541254

12551255
/* This allows UTF8String, IA5String, VisibleString, or BMPString;
12561256
* conversion to UTF-8 is forced. */
1257-
if (d2i_DISPLAYTEXT(&ret, &pp, str->length)) {
1257+
if (d2i_DISPLAYTEXT(&ret, &pp, ASN1_STRING_length(str))) {
12581258
ASN1_STRING_print_ex(bio, ret, ASN1_STRFLGS_UTF8_CONVERT);
12591259
rv = 1;
12601260
}
@@ -1301,7 +1301,7 @@ apr_array_header_t *ssl_ext_list(apr_pool_t *p, conn_rec *c, int peer,
13011301
*/
13021302
array = apr_array_make(p, count, sizeof(char *));
13031303
for (j = 0; j < count; j++) {
1304-
X509_EXTENSION *ext = X509_get_ext(xs, j);
1304+
MODSSL_X509_EXT_CONST X509_EXTENSION *ext = X509_get_ext(xs, j);
13051305

13061306
if (OBJ_cmp(X509_EXTENSION_get_object(ext), oid) == 0) {
13071307
BIO *bio = BIO_new(BIO_s_mem());

modules/ssl/ssl_private.h

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,12 @@
155155
#define MODSSL_SSL_METHOD_CONST
156156
#endif
157157

158+
#if OPENSSL_VERSION_NUMBER >= 0x40000000L
159+
#define MODSSL_X509_EXT_CONST const
160+
#else
161+
#define MODSSL_X509_EXT_CONST
162+
#endif
163+
158164
#if defined(LIBRESSL_VERSION_NUMBER)
159165
/* Missing from LibreSSL */
160166
#if LIBRESSL_VERSION_NUMBER < 0x2060000f
@@ -282,6 +288,10 @@
282288
#define DH_bits(x) (BN_num_bits(x->p))
283289
#define X509_up_ref(x) (CRYPTO_add(&(x)->references, +1, CRYPTO_LOCK_X509))
284290
#define EVP_PKEY_up_ref(pk) (CRYPTO_add(&(pk)->references, +1, CRYPTO_LOCK_EVP_PKEY))
291+
#define ASN1_STRING_get0_data(x) ((x)->data)
292+
#define ASN1_STRING_length(x) ((int)(x)->length)
293+
#define X509_get0_before(x) X509_get_before(x)
294+
#define X509_get0_after(x) X509_get_after(x)
285295
#else
286296
void init_bio_methods(void);
287297
void free_bio_methods(void);
@@ -1212,16 +1222,16 @@ void ssl_log_ssl_error(const char *, int, int, server_rec *);
12121222
* counterparts. */
12131223
void ssl_log_xerror(const char *file, int line, int level,
12141224
apr_status_t rv, apr_pool_t *p, server_rec *s,
1215-
X509 *cert, const char *format, ...)
1225+
const X509 *cert, const char *format, ...)
12161226
__attribute__((format(printf,8,9)));
12171227

12181228
void ssl_log_cxerror(const char *file, int line, int level,
1219-
apr_status_t rv, conn_rec *c, X509 *cert,
1229+
apr_status_t rv, conn_rec *c, const X509 *cert,
12201230
const char *format, ...)
12211231
__attribute__((format(printf,7,8)));
12221232

12231233
void ssl_log_rxerror(const char *file, int line, int level,
1224-
apr_status_t rv, request_rec *r, X509 *cert,
1234+
apr_status_t rv, request_rec *r, const X509 *cert,
12251235
const char *format, ...)
12261236
__attribute__((format(printf,7,8)));
12271237

modules/ssl/ssl_util_ssl.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ char *modssl_bio_free_read(apr_pool_t *p, BIO *bio)
206206
/* Convert ASN.1 string to a pool-allocated char * string, escaping
207207
* control characters. If raw is zero, convert to UTF-8, otherwise
208208
* unchanged from the character set. */
209-
static char *asn1_string_convert(apr_pool_t *p, ASN1_STRING *asn1str, int raw)
209+
char *modssl_ASN1_STRING_convert(apr_pool_t *p, const ASN1_STRING *asn1str, int raw)
210210
{
211211
BIO *bio;
212212
int flags = ASN1_STRFLGS_ESC_CTRL;
@@ -221,13 +221,13 @@ static char *asn1_string_convert(apr_pool_t *p, ASN1_STRING *asn1str, int raw)
221221
return modssl_bio_free_read(p, bio);
222222
}
223223

224-
#define asn1_string_to_utf8(p, a) asn1_string_convert(p, a, 0)
224+
#define asn1_string_to_utf8(p, a) modssl_ASN1_STRING_convert(p, a, 0)
225225

226226
/* convert a NAME_ENTRY to UTF8 string */
227-
char *modssl_X509_NAME_ENTRY_to_string(apr_pool_t *p, X509_NAME_ENTRY *xsne,
227+
char *modssl_X509_NAME_ENTRY_to_string(apr_pool_t *p, const X509_NAME_ENTRY *xsne,
228228
int raw)
229229
{
230-
char *result = asn1_string_convert(p, X509_NAME_ENTRY_get_data(xsne), raw);
230+
char *result = modssl_ASN1_STRING_convert(p, X509_NAME_ENTRY_get_data(xsne), raw);
231231
ap_xlate_proto_from_ascii(result, len);
232232
return result;
233233
}
@@ -236,7 +236,7 @@ char *modssl_X509_NAME_ENTRY_to_string(apr_pool_t *p, X509_NAME_ENTRY *xsne,
236236
* convert an X509_NAME to an RFC 2253 formatted string, optionally truncated
237237
* to maxlen characters (specify a maxlen of 0 for no length limit)
238238
*/
239-
char *modssl_X509_NAME_to_string(apr_pool_t *p, X509_NAME *dn, int maxlen)
239+
char *modssl_X509_NAME_to_string(apr_pool_t *p, const X509_NAME *dn, int maxlen)
240240
{
241241
char *result = NULL;
242242
BIO *bio;
@@ -373,7 +373,7 @@ BOOL modssl_X509_getSAN(apr_pool_t *p, X509 *x509, int type, const char *onf,
373373
/* return an array of (RFC 6125 coined) DNS-IDs and CN-IDs in a certificate */
374374
static BOOL getIDs(apr_pool_t *p, X509 *x509, apr_array_header_t **ids)
375375
{
376-
X509_NAME *subj;
376+
const X509_NAME *subj;
377377
int i = -1;
378378

379379
/* First, the DNS-IDs (dNSName entries in the subjectAltName extension) */

modules/ssl/ssl_util_ssl.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,19 @@ EVP_PKEY *modssl_read_privatekey(const char *filename, pem_password_cb *cb, vo
7171

7272
int modssl_smart_shutdown(SSL *ssl);
7373
BOOL modssl_X509_getBC(X509 *, int *, int *);
74-
char *modssl_X509_NAME_ENTRY_to_string(apr_pool_t *p, X509_NAME_ENTRY *xsne,
74+
char *modssl_X509_NAME_ENTRY_to_string(apr_pool_t *p, const X509_NAME_ENTRY *xsne,
7575
int raw);
76-
char *modssl_X509_NAME_to_string(apr_pool_t *, X509_NAME *, int);
76+
char *modssl_X509_NAME_to_string(apr_pool_t *, const X509_NAME *, int);
7777
BOOL modssl_X509_getSAN(apr_pool_t *, X509 *, int, const char *, int, apr_array_header_t **);
7878
BOOL modssl_X509_match_name(apr_pool_t *, X509 *, const char *, BOOL, server_rec *);
7979
char *modssl_SSL_SESSION_id2sz(IDCONST unsigned char *, int, char *, int);
8080

81+
/* Convert ASN.1 string to a pool-allocated char * string, escaping
82+
* control characters. If raw is zero, convert to UTF-8, otherwise
83+
* unchanged from the character set. */
84+
char *modssl_ASN1_STRING_convert(apr_pool_t *p, const ASN1_STRING *asn1str,
85+
int raw);
86+
8187
/* Reads the remaining data in BIO, if not empty, and copies it into a
8288
* pool-allocated string. If empty, returns NULL. BIO_free(bio) is
8389
* called for both cases. */

support/ab.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -799,7 +799,7 @@ static int ssl_print_connection_info(BIO *bio, SSL *ssl)
799799

800800
static void ssl_print_cert_info(BIO *bio, X509 *cert)
801801
{
802-
X509_NAME *dn;
802+
const X509_NAME *dn;
803803
EVP_PKEY *pk;
804804
char buf[1024];
805805

0 commit comments

Comments
 (0)