Beat Bolli's series from 7 September has three parts. Patch 1 prepares for a renamed ASN1_STRING function in OpenSSL 4.1. Patch 2 fixes an incorrect assumption that ASN1_STRINGs are NUL-terminated. Patch 3 checks the certificate's common name only when no DNS subject alternative names are present, as RFC 6125 defines. The diffstat shows 24 lines added and 9 removed in imap-send.c.
Reviewers have raised problems. Aniket Gupta argued that part of the new code cannot be reached. With SSL_VERIFY_PEER set, SSL_connect() already fails, so a hostname mismatch prints only "certificate verify failed" and does not name the host as the old code did. He asked whether the verify result could be printed when SSL_connect() fails.
Bolli's reply, as it appears in the excerpts, describes a version that uses OpenSSL's own hostname verification. That interface exists since 1.0.2, with a simpler one since 1.1.0. He says it brings all present and future OpenSSL improvements, including IP addresses in subject alternative names, which the old code did not handle, and it prints OpenSSL's error message on failure. The approach was suggested by brian m. carlson, and Bolli says the low-level ASN.1 code would disappear as a result.
Junio Hamano said that topic still needs rework. He thinks patches 1 and 2 can be salvaged with fairly trivial changes, namely a style fix in patch 1 and a fix for pointer arithmetic that breaks a later free() in patch 2. He was unsure how involved it would be to fix patch 3 in the way brian suggested.
Meanwhile, Xiangfei Ding sent a separate patch to use ASN1_STRING_length in host_matches and verify_hostname. Gupta pointed out that it triggers a deprecation warning on OpenSSL 4.1.0-beta2, which fails under DEVELOPER=1, and suggested reconciling it with Bolli's series.