Skip to content

Send RESTART,[P]: instead of bare RESTART on server-initiated restart/exit #1099

Open

Description

@kkalev

Environment

  • Debian Trixie
  • OpenVPN server version: 2.7.5-1~bpo13+1
  • Clients: OpenVPN 2 community (2.7.2) and OpenVPN Connect 3 (3.11.3)
  • Plugin: OpenVPN auth oAuth2 plugin version 2.0.1
  • 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:

  1. Update server restart signal emission to send RESTART,[P]: by default to preserve pushed authentication tokens across restarts.
  2. 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.

Activity

  1. added 2 commits that reference this issue on Nov 24, 2026
    cafdd40
    8cc0a53
  2. spryzz3n commented on Nov 24, 2026

    @spryzz3n

    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 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?

    Thanks!

  3. added a commit that references this issue on Nov 24, 2026
    4d60f15
  4. spryzz3n commented on Nov 24, 2026

    @spryzz3n

    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.

  5. schwabe commented on Nov 24, 2026

    @schwabe
    Contributor

    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.

  6. spryzz3n commented on Nov 24, 2026

    @spryzz3n

    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.

  7. spryzz3n commented on Nov 24, 2026

    @spryzz3n

    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.

    Before:

    Clearing session-id
    Client halt/restart: RESTART psid=0 reason=''
    Creds: Username/Password              -> full re-authentication
    

    After:

    Clearing credentials
    Client halt/restart: RESTART psid=0 reason=''
    Creds: UsernameSessionId/SessionID    -> server: "Username/auth-token authentication succeeded"
    

    Questions before I send it to openvpn-devel:

    • 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.

    Patch: https://github.com/spryzz3n/openvpn3/tree/restart-keep-auth-token

  8. spryzz3n commented on Nov 26, 2026

    @spryzz3n

    Opened a draft PR in openvpn3 with the fix and the two open questions: OpenVPN/openvpn3#451

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions