]> git.ipfire.org Git - thirdparty/git.git/commit
imap-send: explicitly verify the peer certificate
authorJohannes Schindelin <johannes.schindelin@gmx.de>
Mon, 24 Mar 2025 12:28:02 +0000 (12:28 +0000)
committerJunio C Hamano <gitster@pobox.com>
Tue, 25 Mar 2025 22:48:58 +0000 (15:48 -0700)
commitfa8cd29676ca78e83f4218c73033c262d5eeba01
tree2b4980bb57049cee923328f01c8f5f566aeeac9b
parent683c54c999c301c2cd6f715c411407c413b1d84e
imap-send: explicitly verify the peer certificate

It is a bug to obtain the peer certificate without verifying it.

Having said that, from my reading of
https://www.openssl.org/docs/man1.1.1/man3/SSL_set_verify.html, it would
appear that Git is saved by the fact that it calls
`SSL_CTX_set_verify(ctx, SSL_VERIFY_PEER, NULL)` already early on.

In other words, that `SSL_VERIFY_PEER` combined with the `NULL`
parameter (i.e. no overridden callback) would _already_ verify the peer
certificate.  The fact that we later call `SSL_get_peer_certificate()`
is mistaken by CodeQL to mean that that peer certificate still needs to
be verified, but that had already happened at that point.

Nevertheless, it is better to verify the peer certificate explicitly
than to rely on some side effect that is really hard to reason about
(and that took me more than one business day to analyze fully). It also
makes it easier for static analyzers to validate the correctness of the
code.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
imap-send.c