Skip to content

Commit

Permalink
Fix strict client chain check with TLS-1.3
Browse files Browse the repository at this point in the history
When TLS-1.3 is used and the server does not send any CA names
the ca_dn will be NULL. sk_X509_NAME_num() returns -1 on null
argument.

Reviewed-by: Todd Short <todd.short@me.com>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from openssl#17986)
  • Loading branch information
t8m committed Jun 3, 2022
1 parent 336d92e commit 89dd854
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions ssl/t1_lib.c
Expand Up @@ -2870,22 +2870,20 @@ int tls1_check_chain(SSL *s, X509 *x, EVP_PKEY *pk, STACK_OF(X509) *chain,

ca_dn = s->s3.tmp.peer_ca_names;

if (!sk_X509_NAME_num(ca_dn))
if (ca_dn == NULL
|| sk_X509_NAME_num(ca_dn) == 0
|| ssl_check_ca_name(ca_dn, x))
rv |= CERT_PKEY_ISSUER_NAME;

if (!(rv & CERT_PKEY_ISSUER_NAME)) {
if (ssl_check_ca_name(ca_dn, x))
rv |= CERT_PKEY_ISSUER_NAME;
}
if (!(rv & CERT_PKEY_ISSUER_NAME)) {
else
for (i = 0; i < sk_X509_num(chain); i++) {
X509 *xtmp = sk_X509_value(chain, i);

if (ssl_check_ca_name(ca_dn, xtmp)) {
rv |= CERT_PKEY_ISSUER_NAME;
break;
}
}
}

if (!check_flags && !(rv & CERT_PKEY_ISSUER_NAME))
goto end;
} else
Expand Down

0 comments on commit 89dd854

Please sign in to comment.