__X509_NAME_CONST__ X509_NAME *cert_subject;
char *str;
int len;
+ int dnsname_present = 0;
if (ok == 0)
return ok;
for (i = 0; !ok && i < sk_GENERAL_NAME_num(alt_names); i++) {
GENERAL_NAME *name = sk_GENERAL_NAME_value(alt_names, i);
if (name->type == GEN_DNS) {
+ dnsname_present = 1;
#if HA_OPENSSL_VERSION_NUMBER < 0x00907000L
if ((len = ASN1_STRING_to_UTF8((unsigned char **)&str, name->d.ia5)) >= 0) {
#else
cert_subject = X509_get_subject_name(cert);
i = -1;
- while (!ok && (i = X509_NAME_get_index_by_NID(cert_subject, NID_commonName, i)) != -1) {
+ while (!dnsname_present && !ok && (i = X509_NAME_get_index_by_NID(cert_subject, NID_commonName, i)) != -1) {
__X509_NAME_CONST__ X509_NAME_ENTRY *entry = X509_NAME_get_entry(cert_subject, i);
__X509_NAME_CONST__ ASN1_STRING *value;
value = X509_NAME_ENTRY_get_data(entry);