Ticket #65297: patch-alpine-validate-cert.diff
File patch-alpine-validate-cert.diff, 1.7 KB (added by steven-michaud (Steven Michaud), 2 years ago) |
---|
-
imap/src/osdep/unix/ssl_unix.c
old new 554 554 /* Method 2, use cname */ 555 555 if(m == 0 || ret != NIL){ 556 556 cname = X509_get_subject_name(cert); 557 for (j = 0, ret = NIL; j < X509_NAME_entry_count(cname) && ret == NIL; j++){557 for (j = 0, ret = NIL; j < X509_NAME_entry_count(cname); j++) { 558 558 if((e = X509_NAME_get_entry(cname, j)) != NULL){ 559 559 X509_NAME_get_text_by_OBJ(cname, X509_NAME_ENTRY_get_object(e), buf, sizeof(buf)); 560 560 s = (char *) buf; … … 564 564 /* host name matches pattern? */ 565 565 ret = ssl_compare_hostnames (host,s) ? NIL : 566 566 "Server name does not match certificate"; 567 ext = NIL; 567 if (ret == NIL) break; 568 } 569 } 570 ext = NIL; 568 571 /* if mismatch, see if in extensions */ 569 570 572 if (ret && (ext = X509_get_ext_d2i (cert,NID_subject_alt_name,NIL,NIL)) && 573 (n = sk_GENERAL_NAME_num (ext))) 571 574 /* older versions of OpenSSL use "ia5" instead of dNSName */ 572 for (i = 0; ret && (i < n); i++) 573 if ((name = sk_GENERAL_NAME_value (ext,i)) && 574 (name->type = GEN_DNS) && (s = name->d.ia5->data) && 575 ssl_compare_hostnames (host,s)) ret = NIL; 576 if(ext) GENERAL_NAMES_free(ext); 577 } 578 } 575 for (i = 0; ret && (i < n); i++) 576 if ((name = sk_GENERAL_NAME_value (ext,i)) && 577 (name->type = GEN_DNS) && (s = name->d.ia5->data) && 578 ssl_compare_hostnames (host,s)) ret = NIL; 579 if (ext) GENERAL_NAMES_free(ext); 579 580 } 580 581 581 582 if (ret == NIL