Added the rekey-method config option.

This commit is contained in:
Nikos Mavrogiannopoulos
2014-02-22 12:51:34 +01:00
parent 25afdb5949
commit 95a0b6abc3
4 changed files with 37 additions and 7 deletions
+14
View File
@@ -90,6 +90,7 @@ static struct cfg_options available_options[] = {
{ .name = "output-buffer", .type = OPTION_NUMERIC, .mandatory = 0 }, { .name = "output-buffer", .type = OPTION_NUMERIC, .mandatory = 0 },
{ .name = "cookie-validity", .type = OPTION_NUMERIC, .mandatory = 1 }, { .name = "cookie-validity", .type = OPTION_NUMERIC, .mandatory = 1 },
{ .name = "rekey-time", .type = OPTION_NUMERIC, .mandatory = 0 }, { .name = "rekey-time", .type = OPTION_NUMERIC, .mandatory = 0 },
{ .name = "rekey-method", .type = OPTION_STRING, .mandatory = 0 },
{ .name = "auth-timeout", .type = OPTION_NUMERIC, .mandatory = 0 }, { .name = "auth-timeout", .type = OPTION_NUMERIC, .mandatory = 0 },
{ .name = "idle-timeout", .type = OPTION_NUMERIC, .mandatory = 0 }, { .name = "idle-timeout", .type = OPTION_NUMERIC, .mandatory = 0 },
{ .name = "mobile-idle-timeout", .type = OPTION_NUMERIC, .mandatory = 0 }, { .name = "mobile-idle-timeout", .type = OPTION_NUMERIC, .mandatory = 0 },
@@ -251,6 +252,7 @@ unsigned j, mand;
char** auth = NULL; char** auth = NULL;
unsigned auth_size = 0; unsigned auth_size = 0;
unsigned prefix = 0; unsigned prefix = 0;
char *tmp;
unsigned force_cert_auth; unsigned force_cert_auth;
pov = configFileLoad(file); pov = configFileLoad(file);
@@ -393,6 +395,18 @@ unsigned force_cert_auth;
config->rekey_time = 24*60*60; config->rekey_time = 24*60*60;
} }
tmp = NULL;
READ_STRING("rekey-method", tmp);
if (tmp == NULL || strcmp(tmp, "ssl") == 0)
config->rekey_method = REKEY_METHOD_SSL;
else if (strcmp(tmp, "new-tunnel") == 0)
config->rekey_method = REKEY_METHOD_NEW_TUNNEL;
else {
fprintf(stderr, "Unknown rekey method '%s'\n", tmp);
exit(1);
}
free(tmp); tmp = NULL;
READ_NUMERIC("auth-timeout", config->auth_timeout); READ_NUMERIC("auth-timeout", config->auth_timeout);
READ_NUMERIC("idle-timeout", config->idle_timeout); READ_NUMERIC("idle-timeout", config->idle_timeout);
+9
View File
@@ -206,6 +206,15 @@ cookie-validity = 86400
# this amount of seconds is elapsed. Set to zero to disable. # this amount of seconds is elapsed. Set to zero to disable.
rekey-time = 172800 rekey-time = 172800
# ReKey method
# Valid options: ssl, new-tunnel
# ssl: Will perform an efficient rehandshake on the channel allowing
# a seamless connection during rekey.
# new-tunnel: Will instruct the client to discard and re-establish the channel.
# Use this option only if the connecting clients have issues with the ssl
# option.
rekey-method = ssl
# Script to call when a client connects and obtains an IP # Script to call when a client connects and obtains an IP
# Parameters are passed on the environment. # Parameters are passed on the environment.
# REASON, USERNAME, GROUPNAME, HOSTNAME (the hostname selected by client), # REASON, USERNAME, GROUPNAME, HOSTNAME (the hostname selected by client),
+7 -1
View File
@@ -59,6 +59,9 @@
#define AC_PKT_COMPRESSED 8 /* Compressed data */ #define AC_PKT_COMPRESSED 8 /* Compressed data */
#define AC_PKT_TERM_SERVER 9 /* Server kick */ #define AC_PKT_TERM_SERVER 9 /* Server kick */
#define REKEY_METHOD_SSL 1
#define REKEY_METHOD_NEW_TUNNEL 2
extern int syslog_open; extern int syslog_open;
/* the first is generic, for the methods that require a username password */ /* the first is generic, for the methods that require a username password */
@@ -199,7 +202,10 @@ struct cfg_st {
char* socket_file_prefix; char* socket_file_prefix;
time_t cookie_validity; /* in seconds */ time_t cookie_validity; /* in seconds */
time_t rekey_time; /* in seconds */ time_t rekey_time; /* in seconds */
unsigned rekey_method; /* REKEY_METHOD_ */
time_t min_reauth_time; /* after a failed auth, how soon one can reauthenticate -> in seconds */ time_t min_reauth_time; /* after a failed auth, how soon one can reauthenticate -> in seconds */
unsigned auth_timeout; /* timeout of HTTP auth */ unsigned auth_timeout; /* timeout of HTTP auth */
unsigned idle_timeout; /* timeout when idle */ unsigned idle_timeout; /* timeout when idle */
@@ -219,7 +225,7 @@ struct cfg_st {
* TCP sessions. */ * TCP sessions. */
unsigned rate_limit_ms; /* if non zero force a connection every rate_limit milliseconds */ unsigned rate_limit_ms; /* if non zero force a connection every rate_limit milliseconds */
unsigned ping_leases; /* non zero if we need to ping prior to leasing */ unsigned ping_leases; /* non zero if we need to ping prior to leasing */
size_t rx_per_sec; size_t rx_per_sec;
size_t tx_per_sec; size_t tx_per_sec;
unsigned net_priority; unsigned net_priority;
+7 -6
View File
@@ -1286,7 +1286,8 @@ static int connect_handler(worker_st * ws)
(unsigned)(ws->config->rekey_time)); (unsigned)(ws->config->rekey_time));
SEND_ERR(ret); SEND_ERR(ret);
ret = tls_puts(ws->session, "X-CSTP-Rekey-Method: ssl\r\n"); ret = tls_printf(ws->session, "X-CSTP-Rekey-Method: %s\r\n",
(ws->config->rekey_method == REKEY_METHOD_SSL)?"ssl":"new-tunnel");
SEND_ERR(ret); SEND_ERR(ret);
} else { } else {
ret = tls_puts(ws->session, "X-CSTP-Rekey-Method: none\r\n"); ret = tls_puts(ws->session, "X-CSTP-Rekey-Method: none\r\n");
@@ -1378,11 +1379,11 @@ static int connect_handler(worker_st * ws)
(unsigned)(ws->config->rekey_time+10)); (unsigned)(ws->config->rekey_time+10));
SEND_ERR(ret); SEND_ERR(ret);
ret = tls_puts(ws->session, "X-DTLS-Rekey-Method: ssl\r\n"); /* This is our private extension */
SEND_ERR(ret); if (ws->config->rekey_method == REKEY_METHOD_SSL) {
} else { ret = tls_puts(ws->session, "X-DTLS-Rekey-Method: ssl\r\n");
ret = tls_puts(ws->session, "X-DTLS-Rekey-Method: none\r\n"); SEND_ERR(ret);
SEND_ERR(ret); }
} }
ret = ret =