}
isc_nm_streamdnsconnect(netmgr, &localaddr, &query->sockaddr,
tcp_connected, connectquery,
- local_timeout, tlsctx, sess_cache,
+ local_timeout, tlsctx, NULL, sess_cache,
proxy_type, ppi);
#if HAVE_LIBNGHTTP2
} else if (query->lookup->https_mode) {
isc_nm_httpconnect(netmgr, &localaddr, &query->sockaddr, uri,
!query->lookup->https_get, tcp_connected,
- connectquery, tlsctx, sess_cache,
+ connectquery, tlsctx, NULL, sess_cache,
local_timeout, proxy_type, ppi);
#endif
} else {
isc_nm_streamdnsconnect(netmgr, &localaddr, &query->sockaddr,
tcp_connected, connectquery,
- local_timeout, NULL, NULL, proxy_type,
- ppi);
+ local_timeout, NULL, NULL, NULL,
+ proxy_type, ppi);
}
return;
connect_cb, NULL, timeout);
break;
case TCP:
- isc_nm_streamdnsconnect(
- netmgr, &sockaddr_local, &sockaddr_remote, connect_cb,
- NULL, timeout, NULL, NULL, ISC_NM_PROXY_NONE, NULL);
+ isc_nm_streamdnsconnect(netmgr, &sockaddr_local,
+ &sockaddr_remote, connect_cb, NULL,
+ timeout, NULL, NULL, NULL,
+ ISC_NM_PROXY_NONE, NULL);
break;
case DOT: {
isc_tlsctx_createclient(&tls_ctx);
- isc_nm_streamdnsconnect(
- netmgr, &sockaddr_local, &sockaddr_remote, connect_cb,
- NULL, timeout, tls_ctx, NULL, ISC_NM_PROXY_NONE, NULL);
+ isc_nm_streamdnsconnect(netmgr, &sockaddr_local,
+ &sockaddr_remote, connect_cb, NULL,
+ timeout, tls_ctx, NULL, NULL,
+ ISC_NM_PROXY_NONE, NULL);
break;
}
#if HAVE_LIBNGHTTP2
}
isc_nm_httpconnect(netmgr, &sockaddr_local, &sockaddr_remote,
req_url, is_post, connect_cb, NULL, tls_ctx,
- NULL, timeout, ISC_NM_PROXY_NONE, NULL);
+ NULL, NULL, timeout, ISC_NM_PROXY_NONE,
+ NULL);
} break;
#endif
default:
isc_nm_streamdnsconnect(disp->mgr->nm, &disp->local,
&disp->peer, tcp_connected, disp,
- resp->timeout, tlsctx, sess_cache,
+ resp->timeout, tlsctx, NULL, sess_cache,
ISC_NM_PROXY_NONE, NULL);
break;
isc_nm_proxystreamconnect(isc_nm_t *mgr, isc_sockaddr_t *local,
isc_sockaddr_t *peer, isc_nm_cb_t cb, void *cbarg,
unsigned int timeout, isc_tlsctx_t *tlsctx,
+ const char *sni_hostname,
isc_tlsctx_client_session_cache_t *client_sess_cache,
isc_nm_proxyheader_info_t *proxy_info);
/*%<
isc_nm_streamdnsconnect(isc_nm_t *mgr, isc_sockaddr_t *local,
isc_sockaddr_t *peer, isc_nm_cb_t cb, void *cbarg,
unsigned int timeout, isc_tlsctx_t *tlsctx,
+ const char *sni_hostname,
isc_tlsctx_client_session_cache_t *client_sess_cache,
isc_nm_proxy_type_t proxy_type,
isc_nm_proxyheader_info_t *proxy_info);
void
isc_nm_tlsconnect(isc_nm_t *mgr, isc_sockaddr_t *local, isc_sockaddr_t *peer,
isc_nm_cb_t connect_cb, void *connect_cbarg,
- isc_tlsctx_t *ctx,
+ isc_tlsctx_t *ctx, const char *sni_hostname,
isc_tlsctx_client_session_cache_t *client_sess_cache,
unsigned int timeout, bool proxy,
isc_nm_proxyheader_info_t *proxy_info);
void
isc_nm_httpconnect(isc_nm_t *mgr, isc_sockaddr_t *local, isc_sockaddr_t *peer,
const char *uri, bool POST, isc_nm_cb_t cb, void *cbarg,
- isc_tlsctx_t *ctx,
+ isc_tlsctx_t *ctx, const char *sni_hostname,
isc_tlsctx_client_session_cache_t *client_sess_cache,
unsigned int timeout, isc_nm_proxy_type_t proxy_type,
isc_nm_proxyheader_info_t *proxy_info);
void
isc_nm_httpconnect(isc_nm_t *mgr, isc_sockaddr_t *local, isc_sockaddr_t *peer,
const char *uri, bool post, isc_nm_cb_t cb, void *cbarg,
- isc_tlsctx_t *tlsctx,
+ isc_tlsctx_t *tlsctx, const char *sni_hostname,
isc_tlsctx_client_session_cache_t *client_sess_cache,
unsigned int timeout, isc_nm_proxy_type_t proxy_type,
isc_nm_proxyheader_info_t *proxy_info) {
if (tlsctx != NULL) {
isc_nm_tlsconnect(mgr, local, peer,
transport_connect_cb, sock, tlsctx,
- client_sess_cache, timeout, false,
- NULL);
+ sni_hostname, client_sess_cache,
+ timeout, false, NULL);
} else {
isc_nm_tcpconnect(mgr, local, peer,
transport_connect_cb, sock, timeout);
if (tlsctx != NULL) {
isc_nm_tlsconnect(mgr, local, peer,
transport_connect_cb, sock, tlsctx,
- client_sess_cache, timeout, true,
- proxy_info);
+ sni_hostname, client_sess_cache,
+ timeout, true, proxy_info);
} else {
isc_nm_proxystreamconnect(
mgr, local, peer, transport_connect_cb, sock,
- timeout, NULL, NULL, proxy_info);
+ timeout, NULL, NULL, NULL, proxy_info);
}
break;
case ISC_NM_PROXY_ENCRYPTED:
INSIST(tlsctx != NULL);
isc_nm_proxystreamconnect(
mgr, local, peer, transport_connect_cb, sock, timeout,
- tlsctx, client_sess_cache, proxy_info);
+ tlsctx, sni_hostname, client_sess_cache, proxy_info);
break;
default:
UNREACHABLE();
isc_tlsctx_t **listener_tls_ctx; /*%< A context reference per
worker */
size_t n_listener_tls_ctx;
+ char *sni_hostname;
isc_tlsctx_client_session_cache_t *client_sess_cache;
bool client_session_saved;
isc_nmsocket_t *tlslistener;
isc_nm_proxystreamconnect(isc_nm_t *mgr, isc_sockaddr_t *local,
isc_sockaddr_t *peer, isc_nm_cb_t cb, void *cbarg,
unsigned int timeout, isc_tlsctx_t *tlsctx,
+ const char *sni_hostname,
isc_tlsctx_client_session_cache_t *client_sess_cache,
isc_nm_proxyheader_info_t *proxy_info) {
isc_result_t result = ISC_R_FAILURE;
nsock, nsock->connect_timeout);
} else {
isc_nm_tlsconnect(mgr, local, peer, proxystream_connect_cb,
- nsock, tlsctx, client_sess_cache,
- nsock->connect_timeout, false, NULL);
+ nsock, tlsctx, sni_hostname,
+ client_sess_cache, nsock->connect_timeout,
+ false, NULL);
}
}
isc_nm_streamdnsconnect(isc_nm_t *mgr, isc_sockaddr_t *local,
isc_sockaddr_t *peer, isc_nm_cb_t cb, void *cbarg,
unsigned int timeout, isc_tlsctx_t *tlsctx,
+ const char *sni_hostname,
isc_tlsctx_client_session_cache_t *client_sess_cache,
isc_nm_proxy_type_t proxy_type,
isc_nm_proxyheader_info_t *proxy_info) {
} else {
isc_nm_tlsconnect(
mgr, local, peer, streamdns_transport_connected,
- nsock, tlsctx, client_sess_cache,
+ nsock, tlsctx, sni_hostname, client_sess_cache,
nsock->connect_timeout, false, proxy_info);
}
break;
isc_nm_proxystreamconnect(mgr, local, peer,
streamdns_transport_connected,
nsock, nsock->connect_timeout,
- NULL, NULL, proxy_info);
+ NULL, NULL, NULL, proxy_info);
} else {
isc_nm_tlsconnect(
mgr, local, peer, streamdns_transport_connected,
- nsock, tlsctx, client_sess_cache,
+ nsock, tlsctx, sni_hostname, client_sess_cache,
nsock->connect_timeout, true, proxy_info);
}
break;
case ISC_NM_PROXY_ENCRYPTED:
INSIST(tlsctx != NULL);
- isc_nm_proxystreamconnect(mgr, local, peer,
- streamdns_transport_connected, nsock,
- nsock->connect_timeout, tlsctx,
- client_sess_cache, proxy_info);
+ isc_nm_proxystreamconnect(
+ mgr, local, peer, streamdns_transport_connected, nsock,
+ nsock->connect_timeout, tlsctx, sni_hostname,
+ client_sess_cache, proxy_info);
break;
default:
UNREACHABLE();
sock->tlsstream.server = server;
sock->tlsstream.nsending = 0;
sock->tlsstream.state = TLS_INIT;
+ if (sock->tlsstream.sni_hostname != NULL) {
+ INSIST(sock->client);
+ const int ret = SSL_set_tlsext_host_name(
+ sock->tlsstream.tls, sock->tlsstream.sni_hostname);
+ if (ret != 1) {
+ goto error;
+ }
+ }
return ISC_R_SUCCESS;
error:
isc_tls_free(&sock->tlsstream.tls);
void
isc_nm_tlsconnect(isc_nm_t *mgr, isc_sockaddr_t *local, isc_sockaddr_t *peer,
isc_nm_cb_t connect_cb, void *connect_cbarg,
- isc_tlsctx_t *ctx,
+ isc_tlsctx_t *ctx, const char *sni_hostname,
isc_tlsctx_client_session_cache_t *client_sess_cache,
unsigned int timeout, bool proxy,
isc_nm_proxyheader_info_t *proxy_info) {
sock->connect_cbarg = connect_cbarg;
sock->connect_timeout = timeout;
isc_tlsctx_attach(ctx, &sock->tlsstream.ctx);
+ if (sni_hostname != NULL) {
+ sock->tlsstream.sni_hostname =
+ isc_mem_strdup(sock->worker->mctx, sni_hostname);
+ }
sock->client = true;
if (client_sess_cache != NULL) {
INSIST(isc_tlsctx_client_session_cache_getctx(
if (proxy) {
isc_nm_proxystreamconnect(mgr, local, peer, tcp_connected, sock,
sock->connect_timeout, NULL, NULL,
- proxy_info);
+ NULL, proxy_info);
} else {
isc_nm_tcpconnect(mgr, local, peer, tcp_connected, sock,
sock->connect_timeout);
if (sock->tlsstream.ctx != NULL) {
isc_tlsctx_free(&sock->tlsstream.ctx);
}
+ if (sock->tlsstream.sni_hostname != NULL) {
+ isc_mem_free(sock->worker->mctx,
+ sock->tlsstream.sni_hostname);
+ }
if (sock->tlsstream.client_sess_cache != NULL) {
INSIST(sock->client);
isc_tlsctx_client_session_cache_detach(
}
isc_nm_httpconnect(mgr, NULL, &tcp_listen_addr, uri, post,
- connect_send_cb, data, ctx, client_sess_cache,
+ connect_send_cb, data, ctx, NULL, client_sess_cache,
timeout, get_proxy_type(), NULL);
}
ISC_NM_HTTP_DEFAULT_PATH);
isc_nm_httpconnect(connect_nm, NULL, &tcp_listen_addr, req_url,
atomic_load(&POST), timeout_request_cb, NULL, ctx,
- client_sess_cache, T_CONNECT, get_proxy_type(),
+ NULL, client_sess_cache, T_CONNECT, get_proxy_type(),
NULL);
}
isc_nm_httpconnect(connect_nm, NULL, &tcp_listen_addr, req_url,
atomic_load(&POST), doh_connect_send_two_requests_cb,
- NULL, ctx, client_sess_cache, 5000, get_proxy_type(),
- NULL);
+ NULL, ctx, NULL, client_sess_cache, 5000,
+ get_proxy_type(), NULL);
isc_loop_teardown(mainloop, listen_sock_close, listen_sock);
}
static void
tls_connect(isc_nm_t *nm) {
isc_nm_tlsconnect(nm, &tcp_connect_addr, &tcp_listen_addr,
- connect_connect_cb, NULL, tcp_connect_tlsctx,
+ connect_connect_cb, NULL, tcp_connect_tlsctx, NULL,
tcp_tlsctx_client_sess_cache, T_CONNECT,
stream_use_PROXY, NULL);
}
isc_nm_proxystreamconnect(nm, &tcp_connect_addr, &tcp_listen_addr,
connect_connect_cb, NULL, T_CONNECT, tlsctx,
- sess_cache, get_proxyheader_info());
+ NULL, sess_cache, get_proxyheader_info());
}
stream_connect_function
isc_refcount_increment0(&active_cconnects);
if (stream_use_TLS && !stream_PROXY_over_TLS) {
- isc_nm_tlsconnect(
- connect_nm, &tcp_connect_addr, &tcp_listen_addr, cb,
- cbarg, tcp_connect_tlsctx, tcp_tlsctx_client_sess_cache,
- timeout, stream_use_PROXY, NULL);
+ isc_nm_tlsconnect(connect_nm, &tcp_connect_addr,
+ &tcp_listen_addr, cb, cbarg,
+ tcp_connect_tlsctx, NULL,
+ tcp_tlsctx_client_sess_cache, timeout,
+ stream_use_PROXY, NULL);
return;
} else if (stream_use_PROXY) {
isc_tlsctx_t *tlsctx = stream_PROXY_over_TLS
: NULL;
isc_nm_proxystreamconnect(connect_nm, &tcp_connect_addr,
&tcp_listen_addr, cb, cbarg, timeout,
- tlsctx, sess_cache,
+ tlsctx, NULL, sess_cache,
get_proxyheader_info());
return;
} else {
tcpdns_connect(isc_nm_t *nm) {
isc_nm_streamdnsconnect(nm, &tcp_connect_addr, &tcp_listen_addr,
connect_connect_cb, tcpdns_connect, T_CONNECT,
- NULL, NULL, get_proxy_type(), NULL);
+ NULL, NULL, NULL, get_proxy_type(), NULL);
}
ISC_LOOP_TEST_IMPL(tcpdns_noop) {
isc_refcount_increment0(&active_cconnects);
isc_nm_streamdnsconnect(connect_nm, &tcp_connect_addr, &tcp_listen_addr,
connect_success_cb, tcpdns_connect, T_CONNECT,
- NULL, NULL, get_proxy_type(), NULL);
+ NULL, NULL, NULL, get_proxy_type(), NULL);
}
ISC_LOOP_TEST_IMPL(tcpdns_noresponse) {
isc_refcount_increment0(&active_cconnects);
isc_nm_streamdnsconnect(connect_nm, &tcp_connect_addr, &tcp_listen_addr,
connect_connect_cb, tcpdns_connect, T_CONNECT,
- NULL, NULL, get_proxy_type(), NULL);
+ NULL, NULL, NULL, get_proxy_type(), NULL);
}
ISC_LOOP_TEST_IMPL(tcpdns_timeout_recovery) {
tlsdns_connect(isc_nm_t *nm) {
isc_nm_streamdnsconnect(
nm, &tcp_connect_addr, &tcp_listen_addr, connect_connect_cb,
- tlsdns_connect, T_CONNECT, tcp_connect_tlsctx,
+ tlsdns_connect, T_CONNECT, tcp_connect_tlsctx, NULL,
tcp_tlsctx_client_sess_cache, get_proxy_type(), NULL);
}
isc_refcount_increment0(&active_cconnects);
isc_nm_streamdnsconnect(connect_nm, &tcp_connect_addr, &tcp_listen_addr,
connect_success_cb, tlsdns_connect, T_CONNECT,
- tcp_connect_tlsctx,
+ tcp_connect_tlsctx, NULL,
tcp_tlsctx_client_sess_cache, get_proxy_type(),
NULL);
}
isc_refcount_increment0(&active_cconnects);
isc_nm_streamdnsconnect(connect_nm, &tcp_connect_addr, &tcp_listen_addr,
connect_connect_cb, tlsdns_connect, T_CONNECT,
- tcp_connect_tlsctx,
+ tcp_connect_tlsctx, NULL,
tcp_tlsctx_client_sess_cache, get_proxy_type(),
NULL);
}
isc_nm_streamdnsconnect(
connect_nm, &tcp_connect_addr, &tcp_listen_addr,
connect_connect_cb, tlsdns_connect, T_SOFT, tcp_connect_tlsctx,
- tcp_tlsctx_client_sess_cache, get_proxy_type(), NULL);
+ NULL, tcp_tlsctx_client_sess_cache, get_proxy_type(), NULL);
}
ISC_LOOP_TEST_IMPL(tlsdns_recv_one) {