Skip to content

Commit 3ef37f5

Browse files
committed
Ocsigen_http_client: indicate the host name when performing the SSL connection (SNI)
1 parent b806b22 commit 3ef37f5

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/server/ocsigen_http_client.ml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,10 @@ let raw_request
370370
fd sockaddr >>= fun () ->
371371

372372
(if https then
373-
Lwt_ssl.ssl_connect fd !sslcontext
373+
let s = Lwt_ssl.embed_uninitialized_socket fd !sslcontext in
374+
Ssl.set_client_SNI_hostname
375+
(Lwt_ssl.ssl_socket_of_uninitialized_socket s) host;
376+
Lwt_ssl.ssl_perform_handshake s
374377
else
375378
Lwt.return (Lwt_ssl.plain fd))
376379
>>= fun socket ->
@@ -757,7 +760,10 @@ let basic_raw_request
757760
(fun () ->
758761
Lwt_unix.connect fd sockaddr >>= fun () ->
759762
(if https then
760-
Lwt_ssl.ssl_connect fd !sslcontext
763+
let s = Lwt_ssl.embed_uninitialized_socket fd !sslcontext in
764+
Ssl.set_client_SNI_hostname
765+
(Lwt_ssl.ssl_socket_of_uninitialized_socket s) host;
766+
Lwt_ssl.ssl_perform_handshake s
761767
else
762768
Lwt.return (Lwt_ssl.plain fd)))
763769
(handle_connection_error fd)

0 commit comments

Comments
 (0)