Skip to content

Commit dfcdd0b

Browse files
bbolligitster
authored andcommitted
imap-send: use the OpenSSL API to access the subject alternative names
The OpenSSL 4.0 master branch has made the ASN1_STRING structure opaque, forbidding access to its internal fields. Use the official accessor functions instead. They have existed since OpenSSL v1.1.0. Signed-off-by: Beat Bolli <dev+git@drbeat.li> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 67ad421 commit dfcdd0b

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

imap-send.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -244,10 +244,14 @@ static int verify_hostname(X509 *cert, const char *hostname)
244244
if ((subj_alt_names = X509_get_ext_d2i(cert, NID_subject_alt_name, NULL, NULL))) {
245245
int num_subj_alt_names = sk_GENERAL_NAME_num(subj_alt_names);
246246
for (i = 0; !found && i < num_subj_alt_names; i++) {
247+
int ntype;
247248
GENERAL_NAME *subj_alt_name = sk_GENERAL_NAME_value(subj_alt_names, i);
248-
if (subj_alt_name->type == GEN_DNS &&
249-
strlen((const char *)subj_alt_name->d.ia5->data) == (size_t)subj_alt_name->d.ia5->length &&
250-
host_matches(hostname, (const char *)(subj_alt_name->d.ia5->data)))
249+
ASN1_STRING *subj_alt_str = GENERAL_NAME_get0_value(subj_alt_name, &ntype);
250+
251+
if (ntype == GEN_DNS &&
252+
strlen((const char *)ASN1_STRING_get0_data(subj_alt_str)) ==
253+
ASN1_STRING_length(subj_alt_str) &&
254+
host_matches(hostname, (const char *)ASN1_STRING_get0_data(subj_alt_str)))
251255
found = 1;
252256
}
253257
sk_GENERAL_NAME_pop_free(subj_alt_names, GENERAL_NAME_free);

0 commit comments

Comments
 (0)