From bdad0e1534431b36c50aec61e7c8d436c8dcf12b Mon Sep 17 00:00:00 2001 From: Kirthik Aditya Date: Tue, 24 Nov 2026 21:02:21 +0530 Subject: [PATCH] cliproto: keep auth-token on RESTART without [P], like OpenVPN 2.x When the server sends a bare RESTART (without the [P] flag), the OpenVPN 3 client currently purges its session ID (auth-token) while retaining the cached username and password. OpenVPN 2.x handles this differently: it clears the cached username and password but keeps the auth-token. This difference causes OpenVPN 3 clients connected to an OpenVPN 2.x server using --explicit-exit-notify and --auth-gen-token to require interactive authentication (for example, SSO) after a server restart triggered by SIGUSR1, while OpenVPN 2.x clients reconnect using their existing auth-token. Align OpenVPN 3 with the OpenVPN 2.x behaviour: on RESTART without [P], clear the cached username and password while preserving the session ID. HALT handling remains unchanged. If the token is no longer valid, it is cleared through the existing AUTH_FAILED handling. Reported-at: https://github.com/OpenVPN/openvpn/issues/1099 Signed-off-by: Kirthik Aditya --- openvpn/client/cliproto.hpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/openvpn/client/cliproto.hpp b/openvpn/client/cliproto.hpp index 9ad892fe7..535b96aa1 100644 --- a/openvpn/client/cliproto.hpp +++ b/openvpn/client/cliproto.hpp @@ -1597,7 +1597,15 @@ class Session : ProtoContextCallbackInterface, { const ClientHalt ch(msg, true); if (!ch.psid() && creds) - creds->purge_session_id(); + { + // On RESTART, clear the cached username/password but keep the auth-token, + // allowing the client to reconnect without prompting the user. If the token + // is no longer valid, it will be cleared when AUTH_FAILED is received. + if (ch.restart()) + creds->purge_user_pass(); + else + creds->purge_session_id(); + } if (ch.restart()) fatal_ = Error::CLIENT_RESTART; else