Check names in verify callback.

This commit is contained in:
Eric Blankenhorn
2019-10-16 15:08:30 -05:00
parent 6bc16a4acb
commit 9fc33e461c

View File

@@ -9339,13 +9339,24 @@ static int DoVerifyCallback(WOLFSSL* ssl, int ret, ProcPeerCertArgs* args)
#endif
#if defined(OPENSSL_EXTRA)
/* perform domain name check on the peer certificate */
if (args->dCertInit && args->dCert && args->dCert->subjectCN \
&& ssl->param && ssl->param->hostName[0]) {
if(XSTRSTR(args->dCert->subjectCN, ssl->param->hostName) == NULL) {
if (args->dCertInit && args->dCert &&
ssl->param && ssl->param->hostName[0]) {
/* If altNames names is present, then subject common name is ignored */
if (args->dCert->altNames != NULL) {
if (CheckAltNames(args->dCert, ssl->param->hostName) == 0 ) {
return VERIFY_CERT_ERROR;
}
}
else {
if (args->dCert->subjectCN) {
if (MatchDomainName(args->dCert->subjectCN,
args->dCert->subjectCNLen,
ssl->param->hostName) == 0) {
return VERIFY_CERT_ERROR;
}
}
}
}
#endif
/* if verify callback has been set */
if (use_cb && ssl->verifyCallback) {