git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: git@vger.kernel.org
Subject: Re: [RFH/PATCH] imap-send: support SNI (RFC4366)
Date: Wed, 20 Feb 2013 21:35:16 -0800	[thread overview]
Message-ID: <7vr4kaw7or.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <7vbobey0xv.fsf@alter.siamese.dyndns.org> (Junio C. Hamano's message of "Wed, 20 Feb 2013 16:18:04 -0800")

Junio C Hamano <gitster@pobox.com> writes:

> To talk to a site that serves multiple names on a single IP address,
> the client needs to ask for the specific hostname it wants to talk
> to. Otherwise, the default certificate returned from the IP address
> may not match that of the host we wanted to talk to.
>
> Signed-off-by: Junio C Hamano <gitster@pobox.com>
> ---
>
>  * I need help from people on this patch in two areas:
>
>  (1) I only tested this patch by connecting to https://googlemail.com/ 
>      with
> ...
>      I would appreciate it if somebody knows an imap server that
>      needs SNI and runs an end-to-end test against that server.
> 
>  (2) I do not know if everybody has SSL_set_tslext_host_name() macro
>      defined, so this patch may be breaking build for people with
>      different versions of OpenSSL.

What I queued for tonight replaces the posted patch with this
version in order to address (2) above.

-- >8 --
Subject: [PATCH] imap-send: support SNI (RFC4366)

To talk with some sites that serve multiple names on a single IP
address, the client needs to ask for the specific host it wants to
talk to.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 imap-send.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/imap-send.c b/imap-send.c
index 171c887..ab2098a 100644
--- a/imap-send.c
+++ b/imap-send.c
@@ -370,6 +370,17 @@ static int ssl_socket_connect(struct imap_socket *sock, int use_tls_only, int ve
 		return -1;
 	}
 
+#ifdef SSL_CTRL_SET_TLSEXT_HOSTNAME
+	/*
+	 * SNI (RFC4366)
+	 * OpenSSL does not document this function, but the implementation
+	 * returns 1 on success, 0 on failure after calling SSLerr().
+	 */
+	ret = SSL_set_tlsext_host_name(sock->ssl, server.host);
+	if (ret != 1)
+		warning("SSL_set_tslext_host_name(%s) failed.\n", server.host);
+#endif
+
 	ret = SSL_connect(sock->ssl);
 	if (ret <= 0) {
 		socket_perror("SSL_connect", sock, ret);
-- 
1.8.2.rc0.127.g4d5d7da

  reply	other threads:[~2013-02-21  5:35 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-21  0:18 [RFH/PATCH] imap-send: support SNI (RFC4366) Junio C Hamano
2013-02-21  5:35 ` Junio C Hamano [this message]
2013-02-21  5:48   ` Jeff King

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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=7vr4kaw7or.fsf@alter.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    /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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).