On Thu, Nov 12, 2026 at 06:05:34PM +0800, Kevin J. McCarthy wrote:
This is deprecated, and needs to be obtained via a different chain of
calls: X509_NAME_get_index_by_NID(), X509_NAME_get_entry(),
X509_NAME_ENTRY_get_data(), and then ASN1_STRING_to_UTF8() to convert
it to utf8 for comparsion and printing.

Move those calls into x509_get_part(), and change it to store the
output in a BUFFER.

Change check_host() to use x509_get_part() too.

Since x509_get_part() is a general function, move the "Unknown" output
used by interactive_check_cert() into that function instead.

I noticed a bug in both the old and new code inside check_host() when it falls back to checking CN. It was comparing the output of X509_NAME_get_text_by_NID(), which should be in utf-8, against hostname_ascii, which is ascii/punycode.

My patch just swapped out the right hand side of the comparson to be the output of x509_get_part() which was also utf-8, and I failed to notice the left hand side was ascii/punycode.

RFC 9525 actually says NOT to compare against the CN anymore. The current code follows RFC 6125 and only checks CN if there are no DNS entries.

I'll add another commit to the end of the series, like this:

     /* This checks for embedded nuls */
     if (mutt_buffer_len(common_name_buf) == 
mutt_strlen(mutt_b2s(common_name_buf)))
-      match_found = hostname_match(hostname_ascii, mutt_b2s(common_name_buf));
+    {
+      hostname_utf8 = safe_strdup(hostname);
+      if (!mutt_convert_string(&hostname_utf8, Charset, "utf-8", 0))
+        match_found = hostname_match(hostname_utf8, mutt_b2s(common_name_buf));
+    }
   }
if (!match_found)

with hostname_utf8 variable initialization to NULL and a FREE() in the cleanup at the bottom.

Another possibility is just taking out the CN comparison completely. RFC 9525 was issued November 2023. Does anyone have an opinion about that?

--
Kevin J. McCarthy
GPG Fingerprint: 8975 A9B3 3AA3 7910 385C  5308 ADEF 7684 8031 6BDA

Attachment: signature.asc
Description: PGP signature

Reply via email to