]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-ssl-iostream: Fix missing altName handling in openssl_cert_match_name
authorAki Tuomi <aki.tuomi@dovecot.fi>
Tue, 27 Mar 2018 07:29:49 +0000 (10:29 +0300)
committerVille Savolainen <ville.savolainen@dovecot.fi>
Mon, 28 May 2018 06:33:04 +0000 (09:33 +0300)
If name is not found in subjectAltNames, report it as error.

Fixes Panic: file iostream-openssl-common.c: line 177 (openssl_cert_match_name): assertion failed: (*reason_r != NULL)

src/lib-ssl-iostream/iostream-openssl-common.c

index d23159b753d18062c9f8fbac0f6848beb256157c..d79c986ed87ea3e1ef5ab2dfaf64e57e72147170 100644 (file)
@@ -174,8 +174,15 @@ bool openssl_cert_match_name(SSL *ssl, const char *verify_name,
        /* verify against CommonName only when there wasn't any DNS
           SubjectAltNames */
        if (dns_names) {
-               i_assert(*reason_r != NULL);
-               ret = i < count;
+               i_assert(*reason_r != NULL || i == count);
+               if (i == count) {
+                       *reason_r = t_strdup_printf(
+                               "No match to %u SubjectAltNames",
+                               count);
+                       ret = FALSE;
+               } else {
+                       ret = TRUE;
+               }
        } else {
                const char *cname = get_cname(cert);