} else if (!X509_gmtime_adj(X509_get_notAfter(cert.get()), 60*60*24*356*3))
return false;
+ // If the common name is not adapted, also mimic the aliases and subjectAltName
if (properties.mimicCert.get()) {
unsigned char *alStr;
int alLen;
X509_alias_set1(cert.get(), alStr, alLen);
}
- // Add subjectAltName extension used to support multiple hostnames with one certificate
- int pos=X509_get_ext_by_NID (properties.mimicCert.get(), OBJ_sn2nid("subjectAltName"), -1);
- X509_EXTENSION *ext=X509_get_ext(properties.mimicCert.get(), pos);
- if (ext)
- X509_add_ext(cert.get(), ext, -1);
+ if (!properties.setCommonName) {
+ // Add subjectAltName extension used to support multiple hostnames with one certificate
+ int pos=X509_get_ext_by_NID (properties.mimicCert.get(), OBJ_sn2nid("subjectAltName"), -1);
+ X509_EXTENSION *ext=X509_get_ext(properties.mimicCert.get(), pos);
+ if (ext)
+ X509_add_ext(cert.get(), ext, -1);
+ }
}
return true;