Skip to content

Commit 755b621

Browse files
authored
Merge pull request #2707 from pqarmitage/updates
IPVS: add SSL_GET checker sni_name option
2 parents d613698 + 68712b9 commit 755b621

4 files changed

Lines changed: 30 additions & 3 deletions

File tree

doc/man/man5/keepalived.conf.5.in

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2650,8 +2650,10 @@ The syntax for virtual_server is :
26502650
}
26512651

26522652
\fBSSL_GET \fR{
2653-
# when provided, send Server Name Indicator during SSL handshake
2653+
# when provided, send Server Name Indicator during SSL handshake.
26542654
\fBenable_sni\fR
2655+
# If SNI_name is specified, it will be used as the SNI.
2656+
\fBsni_name\fR SNI_name
26552657
# Comply with TLS protocol - send close_notify alert
26562658
# (see SSL_set_quiet_shutdown(3) man page)
26572659
\fBtls_compliant\fR

keepalived/check/check_http.c

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,7 @@ free_http_check(checker_t *checker)
325325

326326
free_url_list(&http_get_chk->url);
327327
free_http_request(http_get_chk->req);
328+
FREE_CONST_PTR(http_get_chk->sni_name);
328329
FREE_CONST_PTR(http_get_chk->virtualhost);
329330
FREE_PTR(http_get_chk);
330331
FREE(checker->co);
@@ -344,6 +345,8 @@ dump_http_check(FILE *fp, const checker_t *checker)
344345
conf_write(fp, " Virtualhost = %s", http_get_chk->virtualhost);
345346
#ifdef _HAVE_SSL_SET_TLSEXT_HOST_NAME_
346347
conf_write(fp, " Enable SNI %sset", http_get_chk->enable_sni ? "" : "un");
348+
if (http_get_chk->sni_name)
349+
conf_write(fp, " SNI name = %s", http_get_chk->sni_name);
347350
#endif
348351
conf_write(fp, " Fast recovery %sset", http_get_chk->fast_recovery ? "" : "un");
349352
if (http_get_chk->proto == PROTO_SSL)
@@ -361,7 +364,6 @@ alloc_http_get(const char *proto)
361364
INIT_LIST_HEAD(&new->url);
362365
new->proto = (!strcmp(proto, "HTTP_GET")) ? PROTO_HTTP : PROTO_SSL;
363366
new->http_protocol = HTTP_PROTOCOL_1_0;
364-
new->virtualhost = NULL;
365367

366368
if (new->proto == PROTO_SSL)
367369
check_data->ssl_required = true;
@@ -396,6 +398,10 @@ compare_http_check(const checker_t *old_c, checker_t *new_c)
396398
return false;
397399
if (old->virtualhost && strcmp(old->virtualhost, new->virtualhost))
398400
return false;
401+
if (!old->sni_name != !new->sni_name)
402+
return false;
403+
if (old->sni_name && strcmp(old->sni_name, new->sni_name))
404+
return false;
399405

400406
list_for_each_entry(u1, &old->url, e_list) {
401407
u2 = (!u2) ? list_first_entry(&new->url, url_t, e_list) :
@@ -851,6 +857,21 @@ enable_sni_handler(const vector_t *strvec)
851857
}
852858
http_get_chk->enable_sni = res;
853859
}
860+
861+
static void
862+
sni_name_handler(const vector_t *strvec)
863+
{
864+
http_checker_t *http_get_chk = current_checker->data;
865+
866+
if (vector_size(strvec) >= 2)
867+
set_string(&http_get_chk->sni_name, strvec, "sni_name");
868+
else if (http_get_chk->sni_name) {
869+
report_config_error(CONFIG_GENERAL_ERROR, "sni_name already specified as %s - ignoring setting to default", http_get_chk->sni_name);
870+
return;
871+
}
872+
873+
http_get_chk->enable_sni = true;
874+
}
854875
#endif
855876

856877
static void
@@ -954,6 +975,7 @@ install_http_ssl_check_keyword(const char *keyword)
954975
install_keyword("http_protocol", &http_protocol_handler);
955976
#ifdef _HAVE_SSL_SET_TLSEXT_HOST_NAME_
956977
install_keyword("enable_sni", &enable_sni_handler);
978+
install_keyword("sni_name", &sni_name_handler);
957979
#endif
958980
install_keyword("fast_recovery", &fast_recovery_handler);
959981
if (!strcmp(keyword, "SSL_GET"))

keepalived/check/check_ssl.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,9 @@ ssl_connect(thread_ref_t thread, int new_req)
266266
#endif
267267
#ifdef _HAVE_SSL_SET_TLSEXT_HOST_NAME_
268268
if (http_get_check->enable_sni) {
269-
if (url && url->virtualhost)
269+
if (http_get_check->sni_name)
270+
vhost.name_const = http_get_check->sni_name;
271+
else if (url && url->virtualhost)
270272
vhost.name_const = url->virtualhost;
271273
else if (http_get_check->virtualhost)
272274
vhost.name_const = http_get_check->virtualhost;

keepalived/include/check_http.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ typedef struct _http_checker {
125125
const char *virtualhost;
126126
#ifdef _HAVE_SSL_SET_TLSEXT_HOST_NAME_
127127
bool enable_sni;
128+
const char *sni_name;
128129
#endif
129130
bool fast_recovery;
130131
bool tls_compliant;

0 commit comments

Comments
 (0)