git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v3 3/3] imap-send: prepare for OpenSSL 4.0

From
Beat Bolli <dev+git@drbeat.li>
Date
Oct 17, 2026, 10:09 UTC
Message-ID
<20261017100956.529225-3-dev+git@drbeat.li>
In-Reply-To
<20261017100956.529225-1-dev+git@drbeat.li>

OpenSSL 4.0 deprecated the SSL_set1_host function if favor of the new function SSL_set1_dnsname, which fortunately takes the same parameters.

Add compatibility #defines for the function and its string variant for the error message.

Signed-off-by: Beat Bolli <dev+git@drbeat.li>
---
 imap-send.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/imap-send.c b/imap-send.c
index ec4e28e423..526bde2f55 100644
--- a/imap-send.c
+++ b/imap-send.c
@@ -248,6 +248,13 @@ static int verify_peer(const SSL *ssl, int did_connect)
 	return 0;
 }
 
+#if (OPENSSL_VERSION_NUMBER < 0x40000000L)
+#define SSL_set1_dnsname(ssl, host) SSL_set1_host((ssl), (host))
+#define SSL_SET_DNSNAME_FN "SSL_set1_host"
+#else
+#define SSL_SET_DNSNAME_FN "SSL_set1_dnsname"
+#endif
+
 static int ssl_socket_connect(struct imap_socket *sock,
 			      const struct imap_server_conf *cfg,
 			      int use_tls_only)
@@ -290,8 +297,8 @@ static int ssl_socket_connect(struct imap_socket *sock,
 	if (cfg->ssl_verify) {
 		/* follow RFC 9525 section 6.3: no partial wildcards */
 		SSL_set_hostflags(sock->ssl, X509_CHECK_FLAG_NO_PARTIAL_WILDCARDS);
-		if (!SSL_set1_host(sock->ssl, cfg->host)) {
-			ssl_socket_perror("SSL_set1_host");
+		if (!SSL_set1_dnsname(sock->ssl, cfg->host)) {
+			ssl_socket_perror(SSL_SET_DNSNAME_FN);
 			return -1;
 		}
 		SSL_set_verify(sock->ssl, SSL_VERIFY_PEER, NULL);
-- 
2.53.0
Previous: Xiangfei DingNext: Patrick Steinhardt
Message 17 of 23 in “imap-send: future proofing and two correctness fixes”
  1. 0/3 imap-send: future proofing and two correctness fixesBeat Bolli, Sep 7, 2026
  2. 3/3 imap-send: only check the CN if no SAN DNS names are presentBeat Bolli, Sep 7, 2026
  3. brian m. carlsonSep 8, 2026
  4. 2/3 imap-send: don't expect an ASN1_STRING to be NUL-terminatedBeat Bolli, Sep 7, 2026
  5. Junio C HamanoSep 8, 2026
  6. Patrick SteinhardtSep 8, 2026
  7. 1/3 imap-send: prepare for OpenSSL 4.1Beat Bolli, Sep 7, 2026
  8. Junio C HamanoSep 8, 2026
  9. Patrick SteinhardtSep 8, 2026
  10. Beat BolliSep 14, 2026
  11. Patrick SteinhardtSep 23, 2026
  12. 1/2 imap-send: use the recommended TLS_method()Beat Bolli, Oct 12, 2026
  13. 1/3 imap-send: use the recommended TLS_method()Beat Bolli, Oct 17, 2026
  14. 2/3 imap-send: let OpenSSL do the hostname verificationBeat Bolli, Oct 17, 2026
  15. Patrick SteinhardtOct 19, 2026
  16. Xiangfei DingOct 19, 2026
  17. 3/3 imap-send: prepare for OpenSSL 4.0Beat Bolli, Oct 17, 2026
  18. Patrick SteinhardtOct 19, 2026
  19. Patrick SteinhardtOct 19, 2026
  20. 2/2 imap-send: let OpenSSL do the hostname verificationBeat Bolli, Oct 12, 2026
  21. Aniket GuptaOct 12, 2026
  22. Xiangfei DingOct 16, 2026
  23. Patrick SteinhardtOct 13, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.