Skip to content

Commit 2a5964a

Browse files
committed
Merge branch 'ob/imap-send-ssl-verify' into maint
Correctly connect to SSL/TLS sites that serve multiple hostnames on a single IP by including Server Name Indication in the client-hello. * ob/imap-send-ssl-verify: imap-send: support Server Name Indication (RFC4366)
2 parents 4bb2121 + 698a1ec commit 2a5964a

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
@@ -304,6 +304,17 @@ static int ssl_socket_connect(struct imap_socket *sock, int use_tls_only, int ve
304304
return -1;
305305
}
306306

307+
#ifdef SSL_CTRL_SET_TLSEXT_HOSTNAME
308+
/*
309+
* SNI (RFC4366)
310+
* OpenSSL does not document this function, but the implementation
311+
* returns 1 on success, 0 on failure after calling SSLerr().
312+
*/
313+
ret = SSL_set_tlsext_host_name(sock->ssl, server.host);
314+
if (ret != 1)
315+
warning("SSL_set_tlsext_host_name(%s) failed.", server.host);
316+
#endif
317+
307318
ret = SSL_connect(sock->ssl);
308319
if (ret <= 0) {
309320
socket_perror("SSL_connect", sock, ret);

0 commit comments

Comments
 (0)