You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Send RESTART,[P]: instead of bare RESTART on server-initiated restart/exit #1099
Use authentication tokens and persistent HHAC keys (directives auth-gen-token 86400 and auth-gen-token-secret [keyfile]
Description / Problem Statement:
When an OpenVPN server initiates a restart/reset (e.g., via SIGUSR1 or explicit management signals), it currently transmits a bare RESTART control message.
This causes inconsistent behavior across client implementations:
OpenVPN 2.x (Community): Reuses the active auth-token stored in memory and reconnects transparently.
OpenVPN Connect 3 (OpenVPN 3 Core): Interprets bare RESTART as a full session reset, purging ephemeral session tokens. Since the oauth2 plugin is in use, this forces users to re-enter credentials/OTP manually with the SSO server (unless the SSO session is already active) rather than completing a seamless background reconnection.
Proposed Solution / Feature Request:
Update server restart signal emission to send RESTART,[P]: by default to preserve pushed authentication tokens across restarts.
Alternatively, provide a configurable server directive to toggle between RESTART and RESTART,[P]: / RESTART,[PN]: behavior.
Impact:
Aligns session persistence across both OpenVPN 2.x and OpenVPN 3 core engines, preventing unnecessary authentication during graceful server restarts or maintenance.
In multi_push_restart_schedule_exit() (src/openvpn/multi.c), the server now sends RESTART,[P]: instead of a bare RESTART when --auth-gen-token is enabled. The existing behaviour is unchanged when token generation is disabled.
A few points worth mentioning:
Limited to auth-gen-token: The [P] flag also tells OpenVPN 2.x clients to retain their cached username and password. I wanted to avoid changing the default behaviour for everyone, so the change only applies when the server is configured to generate authentication tokens.
Exact [P]: prefix: OpenVPN 3 (clihalt.hpp) only preserves the session token when the restart message starts with this exact prefix. Using [PN]: would not work.
[N] behaviour unchanged: When explicit-exit-notify 2 is configured, the server continues to send RESTART,[N] because OpenVPN 3 does not support this flag.
Invalid tokens: If the token cannot be validated after the restart (for example, when --auth-gen-token-secret is not configured), the client receives AUTH_FAILED and falls back to normal authentication.
I've also updated the --explicit-exit-notify documentation and added an entry to Changes.md.
Testing
I've tested the following locally using a UDP server and an OpenVPN 2.x client:
With explicit-exit-notify 1, auth-gen-token and auth-gen-token-secret enabled, sending SIGUSR1 to the server previously resulted in a bare RESTART. With the patch, it sends RESTART,[P]:, and the client reconnects using its existing auth-token without invoking the authentication script again.
Without auth-gen-token, the server continues to send a bare RESTART.
make check passes.
I haven't had a chance to test this with OpenVPN Connect 3 yet.
@kkalev, since you have an SSO setup, would you be able to test this branch with OpenVPN Connect?
Before submitting this to openvpn-devel/Gerrit, I'd appreciate feedback on one point: is tying [P]: to --auth-gen-token the right approach, or would a separate configuration option be preferable?
This sound like you are trying to workaround a bug/different behaviour in OpenVPN 3.x that treats user/password the same way as auth-token in OpenVPN 2.x on the OpenVPN 2.x server side.
In general we want to fix different behaviour of OpenVPN 3.x and 2.x and not have workarounds for different behaviour. This sounds more like you should make a patch/fix for OpenVPN 3.x here.
I see your point about changing the 2.x server behaviour, especially since [P] also affects how clients handle cached credentials.
I'm fine with moving this to OpenVPN 3. Just wanted to confirm: would preserving the auth-token on server-initiated restarts in the OpenVPN 3 client be an acceptable solution?
I'll hold off on the 2.x patch and work on reproducing the issue in OpenVPN 3 in the meantime.
I was able to reproduce this with the OpenVPN 3 test client (ovpncli) against an unmodified 2.x server (explicit-exit-notify 1 + auth-gen-token, then SIGUSR1).
On a bare RESTART, recv_halt_restart() purges the session ID, while the OpenVPN 2.x client keeps the auth-token and clears only the cached username/password. I've changed it to match 2.x: on RESTART without [P], the client clears the cached username/password and keeps the session ID. HALT is unchanged.
Do OpenVPN 3 based servers rely on a bare RESTART making the client drop its session ID (as opposed to RESTART,[P]:)? If so, this change would affect them.
recv_halt_restart() is also called internally when the client rejects a pushed option ("RESTART,rejected pushed option: ..."). With this change the token is kept in that case too. Is that acceptable?
Testing: ctest 36/36 passed (the 6 DCO tests were skipped, as WSL has no ovpn-dco module); git clang-format reports no changes.
Activity
multi: preserve auth-token on server restart when auth-gen-token is e…
multi: preserve auth-token on server restart when auth-gen-token is e…
spryzz3n commentedon Nov 24, 2026
I'd like to get some feedback on this change before submitting it. I've pushed a patch here:
https://github.com/spryzz3n/openvpn/tree/restart-preserve-auth-token
Approach
In
multi_push_restart_schedule_exit()(src/openvpn/multi.c), the server now sendsRESTART,[P]:instead of a bareRESTARTwhen--auth-gen-tokenis enabled. The existing behaviour is unchanged when token generation is disabled.A few points worth mentioning:
auth-gen-token: The[P]flag also tells OpenVPN 2.x clients to retain their cached username and password. I wanted to avoid changing the default behaviour for everyone, so the change only applies when the server is configured to generate authentication tokens.[P]:prefix: OpenVPN 3 (clihalt.hpp) only preserves the session token when the restart message starts with this exact prefix. Using[PN]:would not work.[N]behaviour unchanged: Whenexplicit-exit-notify 2is configured, the server continues to sendRESTART,[N]because OpenVPN 3 does not support this flag.--auth-gen-token-secretis not configured), the client receivesAUTH_FAILEDand falls back to normal authentication.I've also updated the
--explicit-exit-notifydocumentation and added an entry toChanges.md.Testing
I've tested the following locally using a UDP server and an OpenVPN 2.x client:
explicit-exit-notify 1,auth-gen-tokenandauth-gen-token-secretenabled, sending SIGUSR1 to the server previously resulted in a bareRESTART. With the patch, it sendsRESTART,[P]:, and the client reconnects using its existing auth-token without invoking the authentication script again.auth-gen-token, the server continues to send a bareRESTART.make checkpasses.I haven't had a chance to test this with OpenVPN Connect 3 yet.
@kkalev, since you have an SSO setup, would you be able to test this branch with OpenVPN Connect?
Before submitting this to openvpn-devel/Gerrit, I'd appreciate feedback on one point: is tying
[P]:to--auth-gen-tokenthe right approach, or would a separate configuration option be preferable?Thanks!
multi: send RESTART,[P]: on restart when auth-gen-token is used
spryzz3n commentedon Nov 24, 2026
I've sent the patch to openvpn-devel for review:
https://sourceforge.net/p/openvpn/mailman/message/59438417/
Subject: [PATCH] multi: send RESTART,[P]: on restart when auth-gen-token is used
Branch: https://github.com/spryzz3n/openvpn/tree/restart-preserve-auth-token
Testing with OpenVPN Connect 3 would still be very helpful, as I've only verified it with the 2.x client so far.
schwabe commentedon Nov 24, 2026
This sound like you are trying to workaround a bug/different behaviour in OpenVPN 3.x that treats user/password the same way as auth-token in OpenVPN 2.x on the OpenVPN 2.x server side.
In general we want to fix different behaviour of OpenVPN 3.x and 2.x and not have workarounds for different behaviour. This sounds more like you should make a patch/fix for OpenVPN 3.x here.
spryzz3n commentedon Nov 24, 2026
Thanks for the feedback, @schwabe.
I see your point about changing the 2.x server behaviour, especially since
[P]also affects how clients handle cached credentials.I'm fine with moving this to OpenVPN 3. Just wanted to confirm: would preserving the auth-token on server-initiated restarts in the OpenVPN 3 client be an acceptable solution?
I'll hold off on the 2.x patch and work on reproducing the issue in OpenVPN 3 in the meantime.
cliproto: keep auth-token on RESTART without [P], like OpenVPN 2.x
cliproto: keep auth-token on RESTART without [P], like OpenVPN 2.x
spryzz3n commentedon Nov 24, 2026
I was able to reproduce this with the OpenVPN 3 test client (
ovpncli) against an unmodified 2.x server (explicit-exit-notify 1+auth-gen-token, then SIGUSR1).On a bare
RESTART,recv_halt_restart()purges the session ID, while the OpenVPN 2.x client keeps the auth-token and clears only the cached username/password. I've changed it to match 2.x: onRESTARTwithout[P], the client clears the cached username/password and keeps the session ID.HALTis unchanged.Before:
After:
Questions before I send it to openvpn-devel:
RESTARTmaking the client drop its session ID (as opposed toRESTART,[P]:)? If so, this change would affect them.recv_halt_restart()is also called internally when the client rejects a pushed option ("RESTART,rejected pushed option: ..."). With this change the token is kept in that case too. Is that acceptable?Testing:
ctest36/36 passed (the 6 DCO tests were skipped, as WSL has no ovpn-dco module);git clang-formatreports no changes.Patch: https://github.com/spryzz3n/openvpn3/tree/restart-keep-auth-token
cliproto: keep auth-token on RESTART without [P], like OpenVPN 2.x
spryzz3n commentedon Nov 26, 2026
Opened a draft PR in openvpn3 with the fix and the two open questions: OpenVPN/openvpn3#451