]> granicus.if.org Git - neomutt/commitdiff
Add SNI support for OpenSSL. (see #3923)
authorKevin McCarthy <kevin@8t8.us>
Thu, 9 Mar 2017 21:00:10 +0000 (13:00 -0800)
committerRichard Russon <rich@flatcap.org>
Tue, 21 Mar 2017 16:11:38 +0000 (16:11 +0000)
The original patch for this is by Phil Pennock at:
https://people.spodhuis.org/phil.pennock/software/mutt-patches/

I have removed the OpenSSL version check and defined(OPENSSL_NO_TLSEXT)
check because:
  * SSL_set_tlsext_host_name() was added in 0.9.8f [11 Oct 2007]
  * OpenSSL 1.1 no longer has the OPENSSL_NO_TLSEXT compilation option
  * https://rt.openssl.org/Ticket/Display.html?id=2788&user=guest&pass=guest
    shows that the no-tlsext compilation option has been broken for some time.
  * Going forward, I'd like to minimize and start removing cruft required
    to support ancient/insecure versions of libraries.

mutt_ssl.c

index b72e77114b5d9581826ce30a5b7db4d9e334b760..9ab6efc47c5271e56c6128045755ec36aca71eaa 100644 (file)
@@ -558,19 +558,17 @@ static int ssl_negotiate (CONNECTION *conn, sslsockdata* ssldata)
 
   SSL_set_verify (ssldata->ssl, SSL_VERIFY_PEER, ssl_verify_callback);
   SSL_set_mode (ssldata->ssl, SSL_MODE_AUTO_RETRY);
-  ERR_clear_error ();
 
-#if (OPENSSL_VERSION_NUMBER >= 0x0090806fL) && !defined(OPENSSL_NO_TLSEXT)
-  /* TLS Virtual-hosting requires that the server present the correct
-   * certificate; to do this, the ServerNameIndication TLS extension is used.
-   * If TLS is negotiated, and OpenSSL is recent enough that it might have
-   * support, and support was enabled when OpenSSL was built, mutt supports
-   * sending the hostname we think we're connecting to, so a server can send
-   * back the correct certificate.
-   * This has been tested over SMTP against Exim 4.80.
-   * Not yet found an IMAP server which supports this. */
-  SSL_set_tlsext_host_name (ssldata->ssl, conn->account.host);
-#endif
+  if (!SSL_set_tlsext_host_name (ssldata->ssl, conn->account.host))
+  {
+    /* L10N: This is a warning when trying to set the host name for
+     * TLS Server Name Indication (SNI).  This allows the server to present
+     * the correct certificate if it supports multiple hosts. */
+    mutt_error(_("Warning: unable to set TLS SNI host name"));
+    mutt_sleep (1);
+  }
+
+  ERR_clear_error ();
 
   if ((err = SSL_connect (ssldata->ssl)) != 1)
   {