Skip to content

Commit ff1bb13

Browse files
committed
ASN1_STRING has been made opaque in OpenSSL 4
1 parent b04136e commit ff1bb13

2 files changed

Lines changed: 12 additions & 12 deletions

File tree

ext/openssl/openssl_backend_common.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ void php_openssl_add_assoc_name_entry(zval * val, char * key, X509_NAME * name,
108108

109109
void php_openssl_add_assoc_asn1_string(zval * val, char * key, ASN1_STRING * str)
110110
{
111-
add_assoc_stringl(val, key, (char *)str->data, str->length);
111+
add_assoc_stringl(val, key, (const char *)ASN1_STRING_get0_data(str), ASN1_STRING_length(str));
112112
}
113113

114114
time_t php_openssl_asn1_time_to_time_t(ASN1_UTCTIME * timestr)
@@ -140,12 +140,12 @@ time_t php_openssl_asn1_time_to_time_t(ASN1_UTCTIME * timestr)
140140
}
141141

142142
if (timestr_len < 13) {
143-
php_error_docref(NULL, E_WARNING, "Unable to parse time string %s correctly", timestr->data);
143+
php_error_docref(NULL, E_WARNING, "Unable to parse time string %s correctly", ASN1_STRING_get0_data(timestr));
144144
return (time_t)-1;
145145
}
146146

147147
if (ASN1_STRING_type(timestr) == V_ASN1_GENERALIZEDTIME && timestr_len < 15) {
148-
php_error_docref(NULL, E_WARNING, "Unable to parse time string %s correctly", timestr->data);
148+
php_error_docref(NULL, E_WARNING, "Unable to parse time string %s correctly", ASN1_STRING_get0_data(timestr));
149149
return (time_t)-1;
150150
}
151151

@@ -626,8 +626,8 @@ int openssl_x509v3_subjectAltName(BIO *bio, X509_EXTENSION *extension)
626626
}
627627

628628
extension_data = X509_EXTENSION_get_data(extension);
629-
p = extension_data->data;
630-
length = extension_data->length;
629+
p = ASN1_STRING_get0_data(extension_data);
630+
length = ASN1_STRING_length(extension_data);
631631
if (method->it) {
632632
names = (GENERAL_NAMES*) (ASN1_item_d2i(NULL, &p, length,
633633
ASN1_ITEM_ptr(method->it)));

ext/openssl/xp_ssl.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -492,12 +492,12 @@ static bool php_openssl_matches_san_list(X509 *peer, const char *subject_name) /
492492
}
493493
OPENSSL_free(cert_name);
494494
} else if (san->type == GEN_IPADD) {
495-
if (san->d.iPAddress->length == 4) {
495+
if (ASN1_STRING_length(san->d.iPAddress) == 4) {
496496
snprintf(ipbuffer, sizeof(ipbuffer), "%d.%d.%d.%d",
497-
san->d.iPAddress->data[0],
498-
san->d.iPAddress->data[1],
499-
san->d.iPAddress->data[2],
500-
san->d.iPAddress->data[3]
497+
ASN1_STRING_get0_data(san->d.iPAddress)[0],
498+
ASN1_STRING_get0_data(san->d.iPAddress)[1],
499+
ASN1_STRING_get0_data(san->d.iPAddress)[2],
500+
ASN1_STRING_get0_data(san->d.iPAddress)[3]
501501
);
502502
if (strcasecmp(subject_name, (const char*)ipbuffer) == 0) {
503503
sk_GENERAL_NAME_pop_free(alt_names, GENERAL_NAME_free);
@@ -506,9 +506,9 @@ static bool php_openssl_matches_san_list(X509 *peer, const char *subject_name) /
506506
}
507507
}
508508
#ifdef HAVE_IPV6_SAN
509-
else if (san->d.ip->length == 16 && subject_name_is_ipv6) {
509+
else if (ASN1_STRING_length(san->d.ip) == 16 && subject_name_is_ipv6) {
510510
ipbuffer[0] = 0;
511-
EXPAND_IPV6_ADDRESS(ipbuffer, san->d.iPAddress->data);
511+
EXPAND_IPV6_ADDRESS(ipbuffer, ASN1_STRING_get0_data(san->d.iPAddress));
512512
if (strcasecmp((const char*)subject_name_ipv6_expanded, (const char*)ipbuffer) == 0) {
513513
sk_GENERAL_NAME_pop_free(alt_names, GENERAL_NAME_free);
514514

0 commit comments

Comments
 (0)