Git development
 help / color / mirror / Atom feed
From: Patrick Steinhardt <ps@pks.im>
To: Beat Bolli <dev+git@drbeat.li>
Cc: git@vger.kernel.org, Xiangfei Ding <xfding@google.com>,
	Aniket Gupta <aniketgupta3001@gmail.com>,
	Junio C Hamano <gitster@pobox.com>,
	"brian m. carlson" <sandals@crustytoothpaste.net>
Subject: Re: [PATCH v3 2/3] imap-send: let OpenSSL do the hostname verification
Date: Mon, 19 Oct 2026 08:39:08 +0200	[thread overview]
Message-ID: <atW7DJZwHYK_hABy@pks.im> (raw)
In-Reply-To: <20261017100956.529225-2-dev+git@drbeat.li>

On Sat, Oct 17, 2026 at 12:09:55PM +0200, Beat Bolli wrote:
> imap-send performs its own TLS hostname verification. This is not ideal
> because it does not support all certificate features.
> 
> Let's use OpenSSL built-in verification, which is supported in its
> current form since OpenSSL 1.1.0. This gets us all present and future
> improvements done by OpenSSL for free. E.g., the old code did not handle
> IP addresses in the subject alternative names, while the new code does.
> 
> If the verification fails, print the error message as returned by
> OpenSSL.
> 
> [1]: https://wiki.openssl.org/index.php/Hostname_validation
> 
> Suggested-by: brian m. carlson <sandals@crustytoothpaste.net>
> Signed-off-by: Beat Bolli <dev+git@drbeat.li>
> ---
> We cannot easily print the certificate's hostname in case of a mismatch,
> but the cURL branch does not, either.
> 
> Unfortuately, the diff looks bad because two functions are replaced by
> the new verify_peer() function that is completely unrelated.

Would it have been possible to make the diff a bit easier to read, for
example by having a preparatory patch that simply moves code around into
this new `verify_peer()` function without yet changing semantics, and
then changing semantics in a second patch?

> diff --git a/imap-send.c b/imap-send.c
> index 9f21705d77..ec4e28e423 100644
> --- a/imap-send.c
> +++ b/imap-send.c
> @@ -348,20 +320,13 @@ static int ssl_socket_connect(struct imap_socket *sock,
>  	ret = SSL_connect(sock->ssl);
>  	if (ret <= 0) {
>  		socket_perror("SSL_connect", sock, ret);
> +		if (cfg->ssl_verify)
> +			verify_peer(sock->ssl, 0);

Why do we need to verify the certificate when we failed connecting to
the peer? We didn't do that before, either, did we?

Patrick

  reply	other threads:[~2026-10-19  6:39 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-07 21:12 [PATCH 0/3] imap-send: future proofing and two correctness fixes Beat Bolli
2026-09-07 21:12 ` [PATCH 1/3] imap-send: prepare for OpenSSL 4.1 Beat Bolli
2026-09-08  4:17   ` Junio C Hamano
2026-09-08  8:26   ` Patrick Steinhardt
2026-09-14  9:10     ` Beat Bolli
2026-09-23 12:32       ` Patrick Steinhardt
2026-09-07 21:12 ` [PATCH 2/3] imap-send: don't expect an ASN1_STRING to be NUL-terminated Beat Bolli
2026-09-08  1:17   ` Junio C Hamano
2026-09-08  8:26   ` Patrick Steinhardt
2026-09-07 21:12 ` [PATCH 3/3] imap-send: only check the CN if no SAN DNS names are present Beat Bolli
2026-09-08  1:28   ` brian m. carlson
2026-10-12 20:30 ` [PATCH v2 1/2] imap-send: use the recommended TLS_method() Beat Bolli
2026-10-17 10:09   ` [PATCH v3 1/3] " Beat Bolli
2026-10-17 10:09     ` [PATCH v3 2/3] imap-send: let OpenSSL do the hostname verification Beat Bolli
2026-10-19  6:39       ` Patrick Steinhardt [this message]
2026-10-19  8:44       ` Xiangfei Ding
2026-10-17 10:09     ` [PATCH v3 3/3] imap-send: prepare for OpenSSL 4.0 Beat Bolli
2026-10-19  6:39       ` Patrick Steinhardt
2026-10-19  6:39     ` [PATCH v3 1/3] imap-send: use the recommended TLS_method() Patrick Steinhardt
2026-10-12 20:30 ` [PATCH v2 2/2] imap-send: let OpenSSL do the hostname verification Beat Bolli
2026-10-12 22:00   ` Aniket Gupta
2026-10-16 10:56     ` Xiangfei Ding
2026-10-13 13:14   ` Patrick Steinhardt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=atW7DJZwHYK_hABy@pks.im \
    --to=ps@pks.im \
    --cc=aniketgupta3001@gmail.com \
    --cc=dev+git@drbeat.li \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=sandals@crustytoothpaste.net \
    --cc=xfding@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox