Allow Authtoken lifetime to be short than renegotiation time
PATCH 1/1 Allow Authtoken lifetime to be short than renegotiation time
Currently the life time of the auth-token is tied to the reneogotiation time. While this is fine for many setups, some setups prefer a user to be no longer authenticated when the user disconnects from the VPN for a certain amount of time.
This commit allows to shorten the renewal time of the auth-token and ensures that the server resends the auth-token often enough over the existing control channel. This way of updating the auth token is a lot more lightweight than the alternative.
--- doc/man-sections/server-options.rst | 16 ++++--- src/openvpn/auth_token.c | 49 ++++++++++++++++++---- src/openvpn/auth_token.h | 14 +++++-- src/openvpn/forward.c | 15 ++++++- src/openvpn/init.c | 11 +++++ src/openvpn/openvpn.h | 3 ++ src/openvpn/options.c | 24 +++++++++-- src/openvpn/options.h | 2 +- src/openvpn/ssl.c | 8 +++- src/openvpn/ssl_common.h | 7 +++- tests/unit_tests/openvpn/test_auth_token.c | 3 +- 11 files changed, 127 insertions(+), 25 deletions(-)
doc/man-sections/server-options.rst +10 -6
@@ -14,7 +14,7 @@ fast hardware. SSL/TLS authentication must be used in this mode. Valid syntax: :: - auth-gen-token [lifetime] [external-auth] + auth-gen-token [lifetime] [renewal-time] [external-auth] After successful user/password authentication, the OpenVPN server will with this option generate a temporary authentication token and push that
@@ -31,13 +31,17 @@ fast hardware. SSL/TLS authentication must be used in this mode. The lifetime is defined in seconds. If lifetime is not set or it is set to :code:`0`, the token will never expire. + If ``renewal-time`` is not set it defaults to ``renog-sec``. + + The token will expire either after the configured ``lifetime`` of the token is reached or after not being renewed for more than 2 \* - ``reneg-sec`` seconds. Clients will be sent renewed tokens on every TLS - renogiation to keep the client's token updated. This is done to - invalidate a token if a client is disconnected for a sufficiently long - time, while at the same time permitting much longer token lifetimes for - active clients. + ``renewal-time`` seconds. Clients will be sent renewed tokens on every TLS + renogiation. If ``renewal-time`` is lower than ``renog-sec`` the server + will push an updated temporary authentication token every ``reneweal-time`` + seconds. This is done to invalidate a token if a client is disconnected for a + sufficiently long time, while at the same time permitting much longer token + lifetimes for active clients. This feature is useful for environments which are configured to use One Time Passwords (OTP) as part of the user/password authentications and
src/openvpn/auth_token.c +42 -7
78 lines not on this page · raw message
src/openvpn/auth_token.h +11 -3
@@ -46,11 +46,11 @@* (2 * renogiation timeout) * * The session id is a random string of 12 byte (or 16 in base64) that is not -* used by OpenVPN itself but kept intact so that external logging/managment -* can track the session multiple reconnects/servers. It is delibrately chosen +* used by OpenVPN itself but kept intact so that external logging/management +* can track the session multiple reconnects/servers. It is deliberately chosen * be a multiple of 3 bytes to have a base64 encoding without padding. * -* The hmac is calculated over the username contactinated with the +* The hmac is calculated over the username concatenated with the * raw auth-token bytes to include authentication of the username in the token * * We encode the auth-token with base64 and then prepend "SESS_ID_" before
@@ -138,4 +138,12 @@ is_auth_token(const char *password)void resend_auth_token_renegotiation (struct tls_multi *multi,struct tls_session *session); + +/** +* Checks if the timer to resend the auth-token has expired and if a new +* auth-token should be send to the client and triggers the resending +*/ +void +check_send_auth_token (struct context *c); +#endif /* AUTH_TOKEN_H */
src/openvpn/forward.c +14 -1
@@ -42,6 +42,7 @@#include "common.h" #include "ssl_verify.h" #include "dco.h" +#include "auth_token.h" #include "memdbg.h"
@@ -195,9 +196,15 @@ check_tls(struct context *c)interval_schedule_wakeup (&c->c2.tmp_int, &wakeup); -/* Our current code has no good hooks in the TLS machinery to update +/* +* Our current code has no good hooks in the TLS machinery to update * DCO keys. So we check the key status after the whole TLS machinery * has been completed and potentially update them +* +* We have a hidden state transition from secondary to primary key based +* on ks->auth_deferred_expire that DCO needs to check that the normal +* TLS state engine does not check. So we call the doc check even if +* tmp_status does not indicate that something has changed. */ check_dco_key_status (c);
@@ -669,6 +676,12 @@ process_coarse_timers(struct context *c)check_add_routes (c); } +/* check if we want to refresh the auth-token */ +if (event_timeout_trigger (&c->c2.auth_token_renewal_interval, &c->c2.timeval,ETT_DEFAULT )) + { +check_send_auth_token (c); + } +/* possibly exit due to --inactive */ if (c->options.inactivity_timeout &&event_timeout_trigger (&c->c2.inactivity_interval, &c->c2.timeval,ETT_DEFAULT ))
src/openvpn/init.c +11 -0
@@ -1340,6 +1340,16 @@ do_init_timers(struct context *c, bool deferred) } } +/* Arm the timer if we need to renew the auth-token renewal interval is +* shorter than renog-sec to send additional auth-token to ensure the +* token is updated on the client */ +if (c->options.auth_token_generate + && c->options.auth_token_renewal < c->options.renegotiate_seconds) + { +event_timeout_init (&c->c2.auth_token_renewal_interval, + c->options.auth_token_renewal, now); + } +if (!deferred) {/* initialize connection establishment timer */
@@ -3075,6 +3085,7 @@ do_init_crypto_tls(struct context *c, const unsigned int flags) to.auth_user_pass_file = options->auth_user_pass_file; to.auth_token_generate = options->auth_token_generate; to.auth_token_lifetime = options->auth_token_lifetime; + to.auth_token_renewal = options->auth_token_renewal; to.auth_token_call_auth = options->auth_token_call_auth; to.auth_token_key = c->c1.ks.auth_token_key;
src/openvpn/openvpn.h +3 -0
@@ -288,6 +288,9 @@ struct context_2struct event_timeout inactivity_interval;int64_t inactivity_bytes; +/* auth token renewal timer */ +struct event_timeout auth_token_renewal_interval; +/* the option strings must match across peers */ char *options_string_local;char *options_string_remote;
src/openvpn/options.c +21 -3
@@ -2630,6 +2630,14 @@ options_postprocess_verify_ce(const struct options *options,msg (M_USAGE ,"--auth-gen-token needs a non-infinite " "--renegotiate_seconds setting" ); } +if (options->auth_token_generate && options->auth_token_renewal + && options->auth_token_renewal <2 * options->handshake_window) + { +msg (M_USAGE ,"--auth-gen-token reneweal time needs to be at least " +" two times --hand-window (%d)." , + options->handshake_window); + + } {const bool ccnr = (options->auth_user_pass_verify_script || PLUGIN_OPTION_LIST(options)
@@ -3743,6 +3751,10 @@ options_postprocess_mutate(struct options *o, struct env_set *es)foreign_options_copy_dns (o, es);#endif } +if (o->auth_token_generate && !o->auth_token_renewal) + { + o->auth_token_renewal = o->renegotiate_seconds; + }pre_connect_save (o); }
@@ -7461,15 +7473,21 @@ add_option(struct options *options,VERIFY_PERMISSION (OPT_P_GENERAL ); options->auth_token_generate = true; options->auth_token_lifetime = p[1 ] ?positive_atoi (p[1 ]) :0 ; -if (p[2 ]) + +for (int i =2 ; i <MAX_PARMS && p[i] !=NULL ; i++) { -if (streq (p[2 ],"external-auth" )) +/* the second parameter can be the reneweal time */ +if (i ==2 &&positive_atoi (p[i])) + { + options->auth_token_renewal =positive_atoi (p[i]); + } +else if (streq (p[i],"external-auth" )) { options->auth_token_call_auth = true; }else { -msg (msglevel,"Invalid argument to auth-gen-token: %s" , p[2 ]); +msg (msglevel,"Invalid argument to auth-gen-token: %s (%d)" , p[i], i); } }
src/openvpn/options.h +1 -1
@@ -513,9 +513,9 @@ struct optionsconst char *auth_user_pass_verify_script;bool auth_user_pass_verify_script_via_file;bool auth_token_generate; -bool auth_token_gen_secret_file;bool auth_token_call_auth;int auth_token_lifetime; +int auth_token_renewal;const char *auth_token_secret_file;bool auth_token_secret_file_inline;
src/openvpn/ssl.c +6 -2
@@ -3133,8 +3133,12 @@ tls_multi_process(struct tls_multi *multi, ks->state =S_ERROR ; } -/* Update auth token on the client if needed */ -resend_auth_token_renegotiation (multi, session); +/* Update auth token on the client if needed on renegotiation +* (key id !=0) */ +if (session->key[KS_PRIMARY ].key_id !=0 ) + { +resend_auth_token_renegotiation (multi, session); + } } } }
src/openvpn/ssl_common.h +6 -1
@@ -196,7 +196,7 @@ struct key_state {int state;/** The state of the auth-token sent from the client */ -int auth_token_state_flags; +unsigned int auth_token_state_flags;/** * Key id for this key_state, inherited from struct tls_session.
@@ -373,6 +373,7 @@ struct tls_options* options->auth_token_generate. */ bool auth_token_call_auth;/**< always call normal authentication */ unsigned int auth_token_lifetime; +unsigned int auth_token_renewal;struct key_ctx auth_token_key;
@@ -624,6 +625,10 @@ struct tls_multi* user/pass authentications in this session. */ char *auth_token_initial; +/**< Last time an auth-token was generated, this is strictly speaking redundant +* as the auth_token attribute already contains the information but in a +* highly encoded way */ +time_t auth_token_lastgenerated;/**< The first auth-token we sent to a client. We use this to remember * the session ID and initial timestamp when generating new auth-token. */
tests/unit_tests/openvpn/test_auth_token.c +2 -1
@@ -102,7 +102,8 @@ setup(void **state) ctx->session = &ctx->multi.session[TM_ACTIVE ]; ctx->session->opt =calloc (1 ,sizeof (struct tls_options )); - ctx->session->opt->renegotiate_seconds =120 ; + ctx->session->opt->renegotiate_seconds =240 ; + ctx->session->opt->auth_token_renewal =120 ; ctx->session->opt->auth_token_lifetime =3000 ;strcpy (ctx->up.username,"test user name" );
Signature · 1 line
2.37.0 (Apple Git-136)
Hi,
I'm working through this, and have some questions...
Quoted 11 lines · Arne Schwabe
src/openvpn/forward.c +2
-1@@ -195,9 +196,15 @@ check_tls(struct context *c)interval_schedule_wakeup (&c->c2.tmp_int, &wakeup); -/* Our current code has no good hooks in the TLS machinery to update +/* +* Our current code has no good hooks in the TLS machinery to update
src/openvpn/forward.c check_tls(struct context *c) · line 210
Quoted 10 lines
src/openvpn/forward.c +5
-0* DCO keys. So we check the key status after the whole TLS machinery * has been completed and potentially update them +* +* We have a hidden state transition from secondary to primary key based +* on ks->auth_deferred_expire that DCO needs to check that the normal +* TLS state engine does not check. So we call the doc check even if +* tmp_status does not indicate that something has changed. */ check_dco_key_status (c);
This seems unrelated to auth-token, but "escaped from the P2P DCO rework".
I suggest to ignore that hunk.
Quoted 5 lines
src/openvpn/ssl_common.h +0
-0
src/openvpn/ssl_common.h struct tls_multi · line 634
Quoted 10 lines
src/openvpn/ssl_common.h +4
-0@@ -624,6 +625,10 @@ struct tls_multi* user/pass authentications in this session. */ char *auth_token_initial; +/**< Last time an auth-token was generated, this is strictly speaking redundant +* as the auth_token attribute already contains the information but in a +* highly encoded way */ +time_t auth_token_lastgenerated;/**< The first auth-token we sent to a client. We use this to remember * the session ID and initial timestamp when generating new auth-token. */
This is not used at all. I suspect this was coming from an initial approach and later all was done based on event handling.
I suggest to ignore that hunk as well.
The rest looks reasonable (and I'm halfway through applying it, so no need for a v2, just an "yes, please ignore those hunks").
gert
Signature · 6 lines
"If was one thing all people took for granted, was conviction that if you
feed honest figures into a computer, honest figures come out. Never doubted
it myself till I met a computer with a sense of humor."
Robert A. Heinlein, The Moon is a Harsh Mistress
Gert Doering - Munich, Germany [email protected]...PATCH v2 1/1 Allow Authtoken lifetime to be short than renegotiation time
In reply to Arne SchwabeCurrently the life time of the auth-token is tied to the renegotiation time. While this is fine for many setups, some setups prefer a user to be no longer authenticated when the user disconnects from the VPN for a certain amount of time.
This commit allows to shorten the renewal time of the auth-token and ensures that the server resends the auth-token often enough over the existing control channel. This way of updating the auth token is a lot more lightweight than the alternative (frequent renegotiations).
Patch v2: fix grammar mistakes (thanks Gert), fix unit tests
--- doc/man-sections/server-options.rst | 16 ++++--- src/openvpn/auth_token.c | 50 +++++++++++++++++++--- src/openvpn/auth_token.h | 14 ++++-- src/openvpn/forward.c | 7 +++ src/openvpn/init.c | 13 ++++++ src/openvpn/openvpn.h | 3 ++ src/openvpn/options.c | 24 +++++++++-- src/openvpn/options.h | 2 +- src/openvpn/ssl.c | 8 +++- src/openvpn/ssl_common.h | 3 +- tests/unit_tests/openvpn/test_auth_token.c | 12 ++++-- 11 files changed, 126 insertions(+), 26 deletions(-)
doc/man-sections/server-options.rst +10 -6
@@ -14,7 +14,7 @@ fast hardware. SSL/TLS authentication must be used in this mode. Valid syntax: :: - auth-gen-token [lifetime] [external-auth] + auth-gen-token [lifetime] [renewal-time] [external-auth] After successful user/password authentication, the OpenVPN server will with this option generate a temporary authentication token and push that
@@ -31,13 +31,17 @@ fast hardware. SSL/TLS authentication must be used in this mode. The lifetime is defined in seconds. If lifetime is not set or it is set to :code:`0`, the token will never expire. + If ``renewal-time`` is not set it defaults to ``reneg-sec``. + + The token will expire either after the configured ``lifetime`` of the token is reached or after not being renewed for more than 2 \* - ``reneg-sec`` seconds. Clients will be sent renewed tokens on every TLS - renogiation to keep the client's token updated. This is done to - invalidate a token if a client is disconnected for a sufficiently long - time, while at the same time permitting much longer token lifetimes for - active clients. + ``renewal-time`` seconds. Clients will be sent renewed tokens on every TLS + renegotiation. If ``renewal-time`` is lower than ``reneg-sec`` the server + will push an updated temporary authentication token every ``reneweal-time`` + seconds. This is done to invalidate a token if a client is disconnected for a + sufficiently long time, while at the same time permitting much longer token + lifetimes for active clients. This feature is useful for environments which are configured to use One Time Passwords (OTP) as part of the user/password authentications and
src/openvpn/auth_token.c +43 -7
79 lines not on this page · raw message
src/openvpn/auth_token.h +11 -3
@@ -46,11 +46,11 @@* (2 * renogiation timeout) * * The session id is a random string of 12 byte (or 16 in base64) that is not -* used by OpenVPN itself but kept intact so that external logging/managment -* can track the session multiple reconnects/servers. It is delibrately chosen +* used by OpenVPN itself but kept intact so that external logging/management +* can track the session multiple reconnects/servers. It is deliberately chosen * be a multiple of 3 bytes to have a base64 encoding without padding. * -* The hmac is calculated over the username contactinated with the +* The hmac is calculated over the username concatenated with the * raw auth-token bytes to include authentication of the username in the token * * We encode the auth-token with base64 and then prepend "SESS_ID_" before
@@ -138,4 +138,12 @@ is_auth_token(const char *password)void resend_auth_token_renegotiation (struct tls_multi *multi,struct tls_session *session); + +/** +* Checks if the timer to resend the auth-token has expired and if a new +* auth-token should be send to the client and triggers the resending +*/ +void +check_send_auth_token (struct context *c); +#endif /* AUTH_TOKEN_H */
src/openvpn/forward.c +7 -0
@@ -42,6 +42,7 @@#include "common.h" #include "ssl_verify.h" #include "dco.h" +#include "auth_token.h" #include "memdbg.h"
@@ -684,6 +685,12 @@ process_coarse_timers(struct context *c)check_add_routes (c); } +/* check if we want to refresh the auth-token */ +if (event_timeout_trigger (&c->c2.auth_token_renewal_interval, &c->c2.timeval,ETT_DEFAULT )) + { +check_send_auth_token (c); + } +/* possibly exit due to --inactive */ if (c->options.inactivity_timeout &&event_timeout_trigger (&c->c2.inactivity_interval, &c->c2.timeval,ETT_DEFAULT ))
src/openvpn/init.c +13 -0
@@ -1352,6 +1352,18 @@ do_init_timers(struct context *c, bool deferred) } } +/* If the auth-token renewal interval is shorter than reneg-sec, arm +* "auth-token renewal" timer to send additional auth-token to update the +* token on the client more often. If not, this happens automatically +* at renegotiation time, without needing an extra event. +*/ +if (c->options.auth_token_generate + && c->options.auth_token_renewal < c->options.renegotiate_seconds) + { +event_timeout_init (&c->c2.auth_token_renewal_interval, + c->options.auth_token_renewal, now); + } +if (!deferred) {/* initialize connection establishment timer */
@@ -3088,6 +3100,7 @@ do_init_crypto_tls(struct context *c, const unsigned int flags) to.auth_user_pass_file_inline = options->auth_user_pass_file_inline; to.auth_token_generate = options->auth_token_generate; to.auth_token_lifetime = options->auth_token_lifetime; + to.auth_token_renewal = options->auth_token_renewal; to.auth_token_call_auth = options->auth_token_call_auth; to.auth_token_key = c->c1.ks.auth_token_key;
src/openvpn/openvpn.h +3 -0
@@ -290,6 +290,9 @@ struct context_2struct event_timeout session_interval; +/* auth token renewal timer */ +struct event_timeout auth_token_renewal_interval; +/* the option strings must match across peers */ char *options_string_local;char *options_string_remote;
src/openvpn/options.c +21 -3
@@ -2632,6 +2632,14 @@ options_postprocess_verify_ce(const struct options *options,msg (M_USAGE ,"--auth-gen-token needs a non-infinite " "--renegotiate_seconds setting" ); } +if (options->auth_token_generate && options->auth_token_renewal + && options->auth_token_renewal <2 * options->handshake_window) + { +msg (M_USAGE ,"--auth-gen-token reneweal time needs to be at least " +" two times --hand-window (%d)." , + options->handshake_window); + + } {const bool ccnr = (options->auth_user_pass_verify_script || PLUGIN_OPTION_LIST(options)
@@ -3745,6 +3753,10 @@ options_postprocess_mutate(struct options *o, struct env_set *es)foreign_options_copy_dns (o, es);#endif } +if (o->auth_token_generate && !o->auth_token_renewal) + { + o->auth_token_renewal = o->renegotiate_seconds; + }pre_connect_save (o); }
@@ -7469,15 +7481,21 @@ add_option(struct options *options,VERIFY_PERMISSION (OPT_P_GENERAL ); options->auth_token_generate = true; options->auth_token_lifetime = p[1 ] ?positive_atoi (p[1 ]) :0 ; -if (p[2 ]) + +for (int i =2 ; i <MAX_PARMS && p[i] !=NULL ; i++) { -if (streq (p[2 ],"external-auth" )) +/* the second parameter can be the reneweal time */ +if (i ==2 &&positive_atoi (p[i])) + { + options->auth_token_renewal =positive_atoi (p[i]); + } +else if (streq (p[i],"external-auth" )) { options->auth_token_call_auth = true; }else { -msg (msglevel,"Invalid argument to auth-gen-token: %s" , p[2 ]); +msg (msglevel,"Invalid argument to auth-gen-token: %s (%d)" , p[i], i); } }
src/openvpn/options.h +1 -1
@@ -515,9 +515,9 @@ struct optionsconst char *auth_user_pass_verify_script;bool auth_user_pass_verify_script_via_file;bool auth_token_generate; -bool auth_token_gen_secret_file;bool auth_token_call_auth;int auth_token_lifetime; +int auth_token_renewal;const char *auth_token_secret_file;bool auth_token_secret_file_inline;
src/openvpn/ssl.c +6 -2
@@ -3150,8 +3150,12 @@ tls_multi_process(struct tls_multi *multi, ks->state =S_ERROR ; } -/* Update auth token on the client if needed */ -resend_auth_token_renegotiation (multi, session); +/* Update auth token on the client if needed on renegotiation +* (key id !=0) */ +if (session->key[KS_PRIMARY ].key_id !=0 ) + { +resend_auth_token_renegotiation (multi, session); + } } } }
src/openvpn/ssl_common.h +2 -1
@@ -196,7 +196,7 @@ struct key_state {int state;/** The state of the auth-token sent from the client */ -int auth_token_state_flags; +unsigned int auth_token_state_flags;/** * Key id for this key_state, inherited from struct tls_session.
@@ -374,6 +374,7 @@ struct tls_options* options->auth_token_generate. */ bool auth_token_call_auth;/**< always call normal authentication */ unsigned int auth_token_lifetime; +unsigned int auth_token_renewal;struct key_ctx auth_token_key;
tests/unit_tests/openvpn/test_auth_token.c +9 -3
@@ -102,7 +102,8 @@ setup(void **state) ctx->session = &ctx->multi.session[TM_ACTIVE ]; ctx->session->opt =calloc (1 ,sizeof (struct tls_options )); - ctx->session->opt->renegotiate_seconds =120 ; + ctx->session->opt->renegotiate_seconds =240 ; + ctx->session->opt->auth_token_renewal =120 ; ctx->session->opt->auth_token_lifetime =3000 ;strcpy (ctx->up.username,"test user name" );
@@ -187,8 +188,13 @@ auth_token_test_timeout(void **state)assert_int_equal (verify_auth_token (&ctx->up, &ctx->multi, ctx->session),AUTH_TOKEN_HMAC_OK |AUTH_TOKEN_EXPIRED ); -/* Token still in validity, should be accepted */ +/* Token no valid for renegotiate_seconds but still for renewal_time */ now =100000 +2 *ctx->session->opt->renegotiate_seconds -20 ; +assert_int_equal (verify_auth_token (&ctx->up, &ctx->multi, ctx->session), +AUTH_TOKEN_HMAC_OK |AUTH_TOKEN_EXPIRED ); + + + now =100000 +2 *ctx->session->opt->auth_token_renewal -20 ;assert_int_equal (verify_auth_token (&ctx->up, &ctx->multi, ctx->session),AUTH_TOKEN_HMAC_OK );
@@ -213,7 +219,7 @@ auth_token_test_timeout(void **state) AUTH_TOKEN_HMAC_OK);generate_auth_token (&ctx->up, &ctx->multi);strcpy (ctx->up.password, ctx->multi.auth_token); - now += ctx->session->opt->renegotiate_seconds; + now += ctx->session->opt->auth_token_renewal; }
Signature · 1 line
2.37.0 (Apple Git-136)
The feature itself is really in the "we are a swiss army knife and can do everything" side of things. It does not introduce a new option and no new #ifdef, and the actual code change is not very intrusive.
I should point out that there is potential for conflict with the ongoing discussion on username locking - this patch ensures that the username is locked
+ if (!multi->locked_username)
+ {
+ msg(D_SHOW_KEYS, "username not locked, skipping auth-token renewal.");
+ return;
+ }
.. so with my open patch ("do not lock empty username") this will lead to "renewed tokens are only available after first renegotiation", which is certainly not what we want. But Arne did not like that patch anyway, so we need a better fix there.
I have submitted the result to my "server side hard core testing" setup, which does have an --auth-gen-token instance. Without extra options, this does what it did before - new tokens get pushed at renegotiation time, and reconnecting with a valid token bypasses (deliberately slow) auth_pam auth.
With the new option (renewal-time set to 60) I see incoming unsolicited PUSH_REPLY messages:
2022-10-17 18:29:41 Initialization Sequence Completed
2022-10-17 18:30:50 PUSH: Received control message: 'PUSH_REPLY, auth-tokenSESS_ID'
2022-10-17 18:31:54 PUSH: Received control message: 'PUSH_REPLY, auth-tokenSESS_ID'
2022-10-17 18:32:48 PUSH: Received control message: 'PUSH_REPLY, auth-tokenSESS_ID'
2022-10-17 18:33:43 PUSH: Received control message: 'PUSH_REPLY, auth-tokenSESS_ID'(interesting enough, the server claims to have sent these at 18:30:40, 18:31:40, 18:32:40, 18:33:40... - discussed this with Arne: PUSH_REPLY messages are queued only, but tls_process() isn't scheduled, so the dangling message are send when check_tls() is called, every 10-ish seconds. For normal renewal intervals this shouldn't matter, I just found it interesting)
I also have reneg-sec set to 150 on the client, so there's "intermixed" reneg/PUSH_REPLY - but this is fine, we just renew "a bit more often" in this case.
Normal token expiry (600 seconds in my testbed) works as before. "Client offline for too long" expiry is not so easy to test, so I killed the server instead, waited, restarted :-) - when restarting the server quickly, the stored token on the client works perfectly. When waiting for 120 seconds before restarting, we get a clear indication:
2022-10-17 18:42:19 us=660299 194.97.140.21:58930 Timestamp (1666024749) of auth-token is out of the renewal window 2022-10-17 18:42:19 us=660325 194.97.140.21:58930 --auth-gen-token: auth-token from client expired
.. and the client falls back to auth-user-pass, as it should.
I have only tested with a "master" client, but my understanding of the PUSH_REPLY handler is "every version of OpenVPN since ever" handles unsolicited PUSH_REPLY just fine. So testing this with 2.3, 2.4, 2.5 was too much for my lazy self.
Your patch has been applied to the master branch.
commit 9a5161704173e31f2510d3f5c29361f76e275d0f
Author: Arne Schwabe Date: Mon Oct 17 11:51:45 2022 +0200
Allow Authtoken lifetime to be short than renegotiation time
Signed-off-by: Arne Schwabe <[email protected]...>
Acked-by: Gert Doering <[email protected]...>
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg25407.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering