imap-send: support Server Name Indication (RFC4366)
To talk with some sites that serve multiple names on a single IP address, the client needs to ask for the specific host that it wants to talk to. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Junio C Hamano committed
Feb 20, 2013 at 16:02 UTC
698a1ec4d52e90d611c233a12147daf261168bc6
1 file changed
+11
imap-send.c
+11
@@ -370,6 +370,17 @@ static int ssl_socket_connect(struct imap_socket *sock, int use_tls_only, int ve
370
return -1;
371
}
372
373
+#ifdef SSL_CTRL_SET_TLSEXT_HOSTNAME
374
+ /*
375
+ * SNI (RFC4366)
376
+ * OpenSSL does not document this function, but the implementation
377
+ * returns 1 on success, 0 on failure after calling SSLerr().
378
+ */
379
+ ret = SSL_set_tlsext_host_name(sock->ssl, server.host);
380
+ if (ret != 1)
381
+ warning("SSL_set_tlsext_host_name(%s) failed.", server.host);
382
+#endif
383
+
384
ret = SSL_connect(sock->ssl);
385
if (ret <= 0) {
386
socket_perror("SSL_connect", sock, ret);