Skip to content

Commit 698a1ec

Browse files
committed
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 <[email protected]>
1 parent e174744 commit 698a1ec

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

imap-send.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,17 @@ static int ssl_socket_connect(struct imap_socket *sock, int use_tls_only, int ve
370370
return -1;
371371
}
372372

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+
373384
ret = SSL_connect(sock->ssl);
374385
if (ret <= 0) {
375386
socket_perror("SSL_connect", sock, ret);

0 commit comments

Comments
 (0)