]> git.ipfire.org Git - thirdparty/openvpn.git/log
thirdparty/openvpn.git
2 months agoRemove HAVE_EXPORT_KEYING_MATERIAL macro
Max Fillinger [Tue, 27 May 2025 16:03:50 +0000 (18:03 +0200)] 
Remove HAVE_EXPORT_KEYING_MATERIAL macro

This was always defined in all supported versions of OpenSSL and
WolfSSL. EKM is available in mbedtls versions from 2.18.0 onwards.

This commit breaks builds on Debian 11 with the stock mbed TLS package.

Change-Id: Icbfffae877f8eca8d94721a4d54e140c50d4a550
Signed-off-by: MaxF <max@max-fillinger.net>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <20250527160356.10871-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg31799.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 months agodco_linux: avoid bogus text when netlink message is not parsed
Antonio Quartulli [Fri, 23 May 2025 07:38:41 +0000 (09:38 +0200)] 
dco_linux: avoid bogus text when netlink message is not parsed

We may bail out parsing an incoming DCO message because it may
concern a different interface.
In that case we print the following debug messages:

    dco_do_read
    ovpn-dco: ignoring message (type=5) for foreign ifindex 313
    process_incoming_dco: received message of type 0 - ignoring

However, the last message is confusing, because there is no message
of type 0 being received, but the message_type was simply not
initialized.

Bail out parsing earlier and avoid printing any bogus text.

Change-Id: I568faa12a5960e8b69de23c2df413b70b231592c
Signed-off-by: Antonio Quartulli <antonio@mandelbit.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20250523073848.20848-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg31763.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 months agowin: fix collecting DNS exclude data
Heiko Hund [Tue, 20 May 2025 08:55:06 +0000 (10:55 +0200)] 
win: fix collecting DNS exclude data

The size of the returned MULTI_SZ wide domains string was calculated
wrongly. Instead of adding the size of a WCHAR, only the size of a char
was used. As a result, the domains string was stored too short and was
missing the final string terminator.

DHCP assigned DNS server addresses are separated by space, not comma.
These spaces were not replaced by semicolon, as the spec requires.

Github: fixes OpenVPN/openvpn#747
Change-Id: Ie3fcd845344fd0c3ce9a2f99612fb19fe5ebb2f1
Signed-off-by: Heiko Hund <heiko@ist.eigentlich.net>
Acked-by: Lev Stipakov <lstipakov@gmail.com>
Message-Id: <20250520085513.28213-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg31727.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 months agowin: match search domains when creating exclude rules
Heiko Hund [Tue, 20 May 2025 10:51:12 +0000 (12:51 +0200)] 
win: match search domains when creating exclude rules

Compare local domains for exclude rules to search domains and skip
matching ones. This prevents the creation of exclude rules when the
server indicates that the domain should be resolved via the VPN, by
pushing the search domain.

Change-Id: I4919af2b845a47787c08f454b108ef376ea5c0f6
Signed-off-by: Heiko Hund <heiko@ist.eigentlich.net>
Acked-by: Lev Stipakov <lstipakov@gmail.com>
Message-Id: <20250520105119.10431-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg31731.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 months agodns: fix potential NULL pointer dereference
Heiko Hund [Tue, 20 May 2025 07:33:48 +0000 (09:33 +0200)] 
dns: fix potential NULL pointer dereference

Fix issue reported by Coverity (CID 1646952): Dereferencing a pointer
that might be NULL dvf when calling env_set_write_file.

In addition to the fix, inline the write_dns_vars_file() helper function.
Also output a log line in case this error happens, because when it
happens it will hinder communication with the updown runner process, i.e.
setting up / tearing down DNS things will not work as expected.

Change-Id: I275bf939f43577427e14890e7093d63c5213ae5d
Signed-off-by: Heiko Hund <heiko@ist.eigentlich.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20250520073354.17091-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg31720.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 months agoDoxygen: Fix missing parameter warnings
Frank Lichtenheld [Mon, 19 May 2025 14:35:44 +0000 (16:35 +0200)] 
Doxygen: Fix missing parameter warnings

This fixes almost all of the remaining warnings in our
doxygen. Mostly about missing parameters in otherwise
documented functions (completely undocumented functions
do not cause warnings).

Other changes:
 - Exclude out/ directory (used by CMakePresets.json)
 - Output doxygen warnings into a separate file, which
   can be used by CI systems to check for new warnings
 - Increase DOT_GRAPH_MAX_NODES to avoid warnings about
   some of the central header files (syshead.h and buffer.h)

Change-Id: I3bf775bbdea742575210606e174ccafe840677c9
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Arne Schwabe <arne-openvpn@rfc2549.org>
Message-Id: <20250519143550.21761-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg31712.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 months agosocket: don't transfer bind family to socket in case of ANY address
Antonio Quartulli [Tue, 25 Mar 2025 09:01:15 +0000 (10:01 +0100)] 
socket: don't transfer bind family to socket in case of ANY address

With the introduction of multisocket, we need to transfer the
AI family of the bound address to the socket, as it may differ
from what was set globally.

However, this operation makes sense only when getaddrinfo()
for bind is performed on a non-empty hostname.
An empty hostname (ANY) may return AF_INET which will break
following connection attempts to v6 only remotes.

Change-Id: I27f305d3ae9bf650bab409e99173688d9f88ab65
Signed-off-by: Antonio Quartulli <antonio@mandelbit.com>
Acked-by: Arne Schwabe <arne-openvpn@rfc2549.org>
Message-Id: <20250325090121.28813-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg31235.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 months agoMake --dh none behaviour default if not specified
Arne Schwabe [Sun, 18 May 2025 22:02:39 +0000 (00:02 +0200)] 
Make --dh none behaviour default if not specified

Nowadays ciphers that are using still DH and not ECDH are rarely chosen
as best cipher suite. Our man page even indicates that OpenSSL 1.0.1+
supports ECDH cipher suites. So it does not feel useful to force
specifying --dh anymore.

Side note: Custom generated Diffie Hellmann parameters are also
discouraged nowadays. The newest OpenSSL FIPS libraries even flat
out reject them:

   FIPS 186-4 type domain parameters no longer allowed in FIPS mode,
   since the required validation routines were removed from FIPS 186-5

But instead of adding support for loading the well-known curve just make
dh none the default and the recommended option as finite field Diffie
Hellmann is being deprecated anyway
(https://datatracker.ietf.org/doc/draft-ietf-tls-deprecate-obsolete-kex/)
and not supported by TLS 1.3 at all.

Change-Id: Ica02244c9f0ac9b4690a51f940fda9d900465289
Signed-off-by: Arne Schwabe <arne-openvpn@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20250518220245.24489-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg31695.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 months agoExplicit-exit-notify and multisocket interaction
Gianmarco De Gregori [Sun, 18 May 2025 17:23:23 +0000 (19:23 +0200)] 
Explicit-exit-notify and multisocket interaction

Check signals after timeout handling to avoid
unusual delay when using explicit-exit-notify.

Github: fixes OpenVPN/openvpn#702

Change-Id: Id9dbb4d3c550bd4c13f6ee97e67749686457d9fc
Signed-off-by: Gianmarco De Gregori <gianmarco@mandelbit.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20250518172329.21239-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg31688.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 months agoGHA: Dependency and Actions update May 2025
Frank Lichtenheld [Sun, 18 May 2025 15:37:18 +0000 (17:37 +0200)] 
GHA: Dependency and Actions update May 2025

chore(deps): update dependency aws/aws-lc to v1.51.2
chore(deps): update github actions
chore(deps): update dependency libressl/portable to v4.1.0
chore(config): migrate config renovate.json
chore(deps): update vcpkg digest to b12aa38

Change-Id: I515f96c99f92ba144b60e8504cee74915de3efa3
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Yuriy Darnobyt <yura.uddr@gmail.com>
Message-Id: <20250518153724.8099-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg31682.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 months agodns: don't publish env vars to non-dns scripts
Heiko Hund [Sat, 17 May 2025 09:26:26 +0000 (11:26 +0200)] 
dns: don't publish env vars to non-dns scripts

With --dns-updown in place we no longer need --dns option related vars in
the environment for other script hooks. Code for doing that is removed and
the function to set --dns stuff made static, for internal use only.

Change-Id: I3fb01ab76cf3df0874ba92e08f371d17607a8369
Signed-off-by: Heiko Hund <heiko@ist.eigentlich.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20250517092637.2103-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/search?l=mid&q=20250517092637.2103-1-gert@greenie.muc.de
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 months agodns: support running up/down command with privsep
Heiko Hund [Sat, 17 May 2025 08:38:27 +0000 (10:38 +0200)] 
dns: support running up/down command with privsep

With --user privileges are dropped after init. Unfortunately this
affects --dns-updown when undoing previous modifications.

To keep the privileges for just that, the concept of a dns updown runner
in introduced. It's basically a fork of openvpn at the time the
modifications to DNS are made. Its only capability is running the
--dns-updown command when asked to. The parent openvpn process signals
this by writing to a pipe the runner is waiting on.

Commands need to be ready to receive variables from a file instead of the
process environment. A shameless and effective workaround to keep the
protocol between the two processes simple.

Change-Id: I6b67e3a00dd84bf348b6af28115ee11138c3a111
Signed-off-by: Heiko Hund <heiko@ist.eigentlich.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20250517083833.28728-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg31668.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 months agodco_linux: fix peer stats parsing with new ovpn kernel module
Antonio Quartulli [Sat, 17 May 2025 08:32:23 +0000 (10:32 +0200)] 
dco_linux: fix peer stats parsing with new ovpn kernel module

The new ovpn kernel module has changed the netlink attribute
type of the fields containing the pkt/bytes counters in the
peer stats.

We moved from uint64 to uint (a dynamic type can be either
32 or 64 bits), therefore the parsing code must be adapted
accordingly.

While at it, also fix the peer object parsing in the P2P code path.

The fix can be verified by enabling --status with verb 6 and
watching the counters increasing:

2025-05-16 22:23:56 us=649488 dco_get_peer_stats_multi
2025-05-16 22:23:56 us=651008 dco_parse_peer_multi: parsing message...
2025-05-16 22:23:56 us=651734 dco_update_peer_stat / dco_read_bytes: 116280
2025-05-16 22:23:56 us=652682 dco_update_peer_stat / dco_write_bytes: 115776
2025-05-16 22:23:56 us=653467 dco_update_peer_stat / tun_read_bytes: 90048
2025-05-16 22:23:56 us=654110 dco_update_peer_stat / tun_write_bytes: 90048

Change-Id: I104b4adeb9f65cce3487b82f35470174acba92bc
Github: closes OpenVPN/openvpn#746
Signed-off-by: Antonio Quartulli <antonio@mandelbit.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20250517083231.27977-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg31666.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 months agofix typo in haikuos dns-updown script
Heiko Hund [Thu, 15 May 2025 15:29:44 +0000 (17:29 +0200)] 
fix typo in haikuos dns-updown script

Change-Id: I8ca39e8c175909c62447dc28eea7035446330929
Signed-off-by: Heiko Hund <heiko@ist.eigentlich.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20250515152950.1329-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg31656.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 months agoImplement ovpn version detection
Ralf Lici [Thu, 15 May 2025 15:00:31 +0000 (17:00 +0200)] 
Implement ovpn version detection

Add detection of the ovpn kernel module type: if a backported
(out-of-tree) version is loaded, the MODULE_VERSION string is read from
sysfs; otherwise, for the in-tree module, the function reports the
kernel release and version.

Change-Id: I7fc033a7ffee73045316763356a95d75ef23f5ad
Signed-off-by: Ralf Lici <ralf@mandelbit.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20250515150038.30097-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg31652.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 months agodns: apply settings via script on unixoid systems
Heiko Hund [Wed, 14 May 2025 13:53:27 +0000 (15:53 +0200)] 
dns: apply settings via script on unixoid systems

This introduces a new script hook, the dns-updown, and implements such a
command script for a few popular systems (and a default for the not so
popular ones). Like the name suggests this hook is soleley for dealing
with modifying how names are resolved when the VPN pushes some --dns
settings.

The default dns updown command is part of the distribution and is
installed with openvpn. You can change the path the command is located
at as a compile time option, defaults to libexecdir.

You can compile-time disable that the default dns-updown hook is
run by passing --disable-dns-updown-by-default to configure or
ccmake ENABLE_DNS_UPDOWN_BY_DEFAULT to OFF.

There's also a new runtime option --dns-updown, which can run a custom
command, force running the default when disabled or disable execution
of the dns-updown altogether.

Change-Id: Ifbe4ffb44d3bfcaa50adb38cacb3436fcdc71b10
Signed-off-by: Heiko Hund <heiko@ist.eigentlich.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20250514135334.14377-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg31639.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 months agowin: remove Wintun support
Lev Stipakov [Tue, 13 May 2025 15:09:59 +0000 (17:09 +0200)] 
win: remove Wintun support

Since DCO supports modern ciphers and server mode,
there is no reason to support Wintun anymore.

This also removes --windows-driver option support. The
default driver is DCO, as it has been since 2.6. If for
some reasons one doesn't want to use it, --disable-dco
multiplatform option will switch to tap-windows6.

Change-Id: I43ec390040bffeec05270271ea7fb54fb219c536
Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20250513151006.13617-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg31631.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 months agowin: create adapter on demand
Lev Stipakov [Sat, 10 May 2025 18:19:30 +0000 (20:19 +0200)] 
win: create adapter on demand

The installer currently creates one adapter per driver. When a user tries
to start a second VPN connection while another is active, the client
fails with an unclear error message:

  "All ovpn-dco adapters on this system are currently in use or disabled."

This message does not guide the user toward resolving the issue, such as by
running the shortcut "Add a new dco-win virtual network adapter."

To improve user experience, the client will now create an adapter on demand
when no available adapters exist. The client sends a command specifying
the adapter type to the interactive service, which then executes tapctl.exe
to create a new adapter.

This feature requires the interactive service, but this should not pose a
problem since even our automatic service has recently started relying on the
interactive service.

GitHub: OpenVPN/openvpn#728

Change-Id: I621d44ec6b0facc524875c15ddfd11ec47b06c15
Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Selva Nair <selva.nair@gmail.com>
Message-Id: <20250510181937.2993-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg31617.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 months agoCMake: Reorganize header and symbol tests
Frank Lichtenheld [Thu, 8 May 2025 17:46:15 +0000 (19:46 +0200)] 
CMake: Reorganize header and symbol tests

When we check for the header and then symbols
in that header combine this so that the
relationship between the tests is clear and
that we do not do tests we know will fail.

Change-Id: I0c4fce76c81c5297ff5469d787114f1279bf35e5
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Arne Schwabe <arne-openvpn@rfc2549.org>
Message-Id: <20250508174624.7504-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg31602.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 months agoCMake: Sync list of compiler flags with configure.ac
Frank Lichtenheld [Fri, 9 May 2025 09:09:31 +0000 (11:09 +0200)] 
CMake: Sync list of compiler flags with configure.ac

Also fix one issue reported by the build.

Change-Id: I28af9eac2e9fb615903a82c8f4087602b72c134d
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Arne Schwabe <arne-openvpn@rfc2549.org>
Message-Id: <20250509090936.18818-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg31604.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 months agoCMake: Make sure to treat UNIT_TEST_SOURCEDIR as path
Frank Lichtenheld [Wed, 7 May 2025 12:12:20 +0000 (14:12 +0200)] 
CMake: Make sure to treat UNIT_TEST_SOURCEDIR as path

This makes sure that it is properly normalized, and
on Windows seems to prevent CMake from using back
slashes which would break the build due to "unknown escape
sequence" errors.

Change-Id: I2551edfaaf5107649398a3fa1db2009ee8644671
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Arne Schwabe <arne-openvpn@rfc2549.org>
Message-Id: <20250507121226.13824-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg31587.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 months agowin: refactor get_windows_version()
Lev Stipakov [Mon, 5 May 2025 12:27:06 +0000 (14:27 +0200)] 
win: refactor get_windows_version()

It's 2025, and almost all clients now run on Windows 10 or newer.
Instead of displaying:

  "Windows version 10.0 (Windows 10 or greater), amd64 executable"

we now show the exact build number, e.g.:

  "Windows version: 10.0.22631,amd64"

Remove "pre-Win7" checks in a few places.

Change-Id: I39d660ebeec76280e4d4357192b74bf2c0980615
Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20250505122712.5214-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg31566.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 months agoAdd information-gathering about DNS resolvers configured to t_client.sh(.in)
Gert Doering [Mon, 5 May 2025 14:22:16 +0000 (16:22 +0200)] 
Add information-gathering about DNS resolvers configured to t_client.sh(.in)

With the patchsets to add DNS configuration on Unix+MacOS systems, and
the addition of test stanzas to excercise and verify the OS specific
"dns-updown" script, it becomes important to trace test failures
("did it not ping because the DNS was not installed, or did something
else fail?") and also verify that DNS config is properly restored at
the end of each test.

Linux is probed with "resolvectl status", if available, and
"cat resolv.conf" if not.  MacOS uses scutil --dns.

All other platforms use "cat resolv.conf" for now (because even if
"a tool to maintain DNS config" is available, in the end resolv.conf
is always where the final config lands).

Include a bit of restructuring to handle linux iproute2 testing in the
"Linux" branch, and make the control flow more amenable to having a
second case / esac block.

Change-Id: I9cae7314203424e4a604073c5445559260172477
Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <20250505142224.24935-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg31568.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 months agoManually reformat some long trailing comments
Frank Lichtenheld [Mon, 5 May 2025 10:54:43 +0000 (12:54 +0200)] 
Manually reformat some long trailing comments

When trying to reformat the code with a formatter
that actually checks line-lengths, these never
come out nice otherwise.

Change-Id: I7f0ba2261b61f6eed511cbd8bb2e880d774d1365
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20250505105449.18826-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg31561.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 months agodco_linux: Introduce new uAPIs
Gianmarco De Gregori [Mon, 5 May 2025 08:57:14 +0000 (10:57 +0200)] 
dco_linux: Introduce new uAPIs

This patch updates the dco userspace API to
support communication with the new in-kernel
driver.

The main change involves updating the enums
used for Netlink messages to match the
definitions expected by the kernel module.

Change-Id: I009f4e7ad38636f1c0b78d267561194c2bb4c051
Signed-off-by: Gianmarco De Gregori <gianmarco@mandelbit.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20250505085722.28761-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg31554.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 months agoFix tmp-dir documentation
Klemens Nanni [Sat, 26 Apr 2025 12:19:03 +0000 (15:19 +0300)] 
Fix tmp-dir documentation

Mention its default (on non-Windows systems), rephrase for brevity, fix
grammar, correct the module environment variable name and remove a wrong
default mentioned in a related option.
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <20250426121903.67930-1-kn@openbsd.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg31514.html

Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 months agoFix mbed TLS key exporter functionality in 3.6.x and cmake
Arne Schwabe [Fri, 25 Apr 2025 13:09:54 +0000 (15:09 +0200)] 
Fix mbed TLS key exporter functionality in 3.6.x and cmake

Cmake did not check for the mbedtls_ssl_set_export_keys_cb symbol
when generating an mbed TLS configuration. This causes no actual
working key exporter to be in the binary.

Also add an explicit #error to catch this situation during compilation.

Change-Id: If38e80e268dc0ee7e57de2c175c5b4db0ce55ed0
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <20250425131002.21772-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg31510.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 months agossl_openssl.c: Prevent potential double-free
Lev Stipakov [Thu, 17 Apr 2025 13:46:30 +0000 (15:46 +0200)] 
ssl_openssl.c: Prevent potential double-free

Fixes a potential double-free issue in tls_ctx_load_cert_uri()
by explicitly nullifying the pointer immediately after calling
OSSL_STORE_INFO_free(info).

This ensures that subsequent cleanup won't attempt to free the same
structure again.

Github: closes OpenVPN/openvpn#726

Change-Id: I4507be07cd5573b2117e837ef03187535a38a4b1
Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Antonio Quartulli <antonio@mandelbit.com>
Message-Id: <20250417134636.21279-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg31478.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 months agowin: allow OpenVPN service account to use any command-line options
Lev Stipakov [Tue, 15 Apr 2025 15:51:24 +0000 (17:51 +0200)] 
win: allow OpenVPN service account to use any command-line options

Since 2.7, OpenVPN service (used to start persistent connections)
runs under limited virtual service account NT SERVICE\OpenVPNService.

Since it should be able to use all command-line options
and cannot be made member of "OpenVPN Administrators" group,
it has to be handled separately.

Change-Id: I44d308301dfb7c22600d8632a553288f52b3068f
Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20250415155131.12458-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg31435.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 months agoDoxygen: Remove useless Python information
Frank Lichtenheld [Tue, 15 Apr 2025 15:56:50 +0000 (17:56 +0200)] 
Doxygen: Remove useless Python information

Do not include information for the trivial Python
scripts we have. Completely eliminates the "Namespaces"
page as well.

Change-Id: Ia7186b528773c0549748f1051c1c8d1db39a7e11
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Arne Schwabe <arne-openvpn@rfc2549.org>
Message-Id: <20250415155656.12963-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg31433.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 months agoDoxygen: Clean up tls-crypt documentation
Frank Lichtenheld [Tue, 15 Apr 2025 15:57:11 +0000 (17:57 +0200)] 
Doxygen: Clean up tls-crypt documentation

- Fix broken links to OpenSSL documentation
- Remove some unnecessary \c for function names.
  Doxygen does handle them automatically.
- Add some \c for --option since otherwise --
  gets converted to one character (e.g. &ndash; in
  HTML).

Change-Id: I9a27248557fabcd9f7584deb4aba16cd71fb803c
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Arne Schwabe <arne-openvpn@rfc2549.org>
Message-Id: <20250415155720.13034-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg31434.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 months agoRemove UINT8_MAX definition
Lev Stipakov [Tue, 15 Apr 2025 15:52:53 +0000 (17:52 +0200)] 
Remove UINT8_MAX definition

Because this is a part of C99 if uint8_t is available.

Change-Id: I37482a8c322680add00bab52272f9945fbb3bd09
Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20250415155259.12601-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg31440.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 months agowin: implement --dns option support with NRPT
Heiko Hund [Mon, 14 Apr 2025 18:06:26 +0000 (20:06 +0200)] 
win: implement --dns option support with NRPT

Implement support for setting options from --dns. This is hugely
different than what we had so far with DNS related --dhcp-option.

The main difference it that we support split DNS and DNSSEC by making
use of NRPT (Name Resolution Policy Table). Also OpenVPN tries to keep
local DNS resolution working when DNS is redirected into the tunnel. To
prevent this from happening we have --block-outside-dns, in case you
wonder. Basically we collect domains and name server addresses from
network adapters and add so called exclude NRPT rules in addition to the
catch all rule that is pushed by the server.

All is done via the interactive service, since modifying all this
requires the elevated privileges that the openvpn process hopefully
doesn't have.

Change-Id: I576e74f3276362606e9cbd50bb5adbebaaf209cc
Signed-off-by: Heiko Hund <heiko@ist.eigentlich.net>
Acked-by: Lev Stipakov <lstipakov@gmail.com>
Message-Id: <20250414180636.31936-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg31426.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 months agoFix dco_win and multisocket interaction
Gianmarco De Gregori [Thu, 10 Apr 2025 21:50:29 +0000 (23:50 +0200)] 
Fix dco_win and multisocket interaction

The recent introduction of the multisocket support
did not account for some Windows-specific DCO paths.
This patch restores correct behavior on Windows.

Key changes:

 - Add WIN32 guards around DCO-specifc code.
 - Disable wait_signal() when running in
   server mode, as it conflicts with the
   event engine since Windows handles
   signals as I/Os.
 - Ensure correct socket handling for TCP
   vs UDP.

Github: closes openvpn/OpenVPN#720

Change-Id: I719b1aa2d2f4d63dc9c18d8e313fba339e3e4b0c
Signed-off-by: Gianmarco De Gregori <gianmarco@mandelbit.com>
Acked-by: Lev Stipakov <lstipakov@gmail.com>
Message-Id: <20250410215037.11878-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg31419.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 months agoGHA: Use CMake 4.0 and apply required fixes
Frank Lichtenheld [Wed, 9 Apr 2025 13:11:42 +0000 (15:11 +0200)] 
GHA: Use CMake 4.0 and apply required fixes

- update vcpkg reference to 856505bb76
  This includes a general work-around for the CMake 4.0
  compat. See commit
  a1aebfa9d5eae7cf493e0a706b43915d687bb860.
- update lukka/get-cmake action to v4
- update dependency aws/aws-lc to v1.49.1

Change-Id: Ibabb4aa80d7786614dbd6b76bd4cd096f217acfd
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Yuriy Darnobyt <yura.uddr@gmail.com>
Message-Id: <20250409131148.18147-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg31399.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 months agoDoxygen: Fix obsolete links to OpenSSL documentation
Frank Lichtenheld [Wed, 9 Apr 2025 12:53:31 +0000 (14:53 +0200)] 
Doxygen: Fix obsolete links to OpenSSL documentation

Change-Id: Iabef94b36bae16b2c8288b15b14d660ecb06842d
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20250409125336.5835-1-gert@greenie.muc.de>
URL: https://sourceforge.net/p/openvpn/mailman/message/59171340/
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 months agoAlso print key agreement when printing negotiated details
Arne Schwabe [Wed, 9 Apr 2025 12:24:03 +0000 (14:24 +0200)] 
Also print key agreement when printing negotiated details

With TLS 1.0 to 1.2, the used key agreement was depended on the certificates
themselves. With TLS 1.3 this is no longer the case but basically always
X25519 was used.  So this information has not been very interesting so far.

With OpenSSL 3.5.0 and the new X25519MLKEM768 hybrid key agreement, the used
key agreement group actually becomes interesting information.

This commit adds printing this information for OpenSSL 3.0.0+ and uses
a compat version for OpenSSL 3.0-3.1 to avoid an additional ifdef in the
code itself.

Example output with ML-DSA-65 certificates on the server (client output):

   Control Channel: TLSv1.3, cipher
   TLSv1.3 TLS_AES_256_GCM_SHA384, peer certificate: 15616
   bits ML-DSA-65, signature: id-ml-dsa-65, peer signing
   digest/type: mldsa65 id-ml-dsa-65,
   key agreement: X25519MLKEM768

with an secp384r1 certificate:

  Control Channel: TLSv1.3, cipher
  TLSv1.3 TLS_AES_256_GCM_SHA384, peer certificate: 384
  bits ECsecp384r1, signature: ecdsa-with-SHA256, peer signing
  digest/type: ecdsa_secp384r1_sha384 ECDSA,
  key agreement: X25519MLKEM768

Change-Id: I90d54853fe1b1d820661cc2c099e07ec5d31ed05
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20250409122409.17616-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg31393.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 months agoUse USER_PASS_LEN instead of TLS_USERNAME_LEN for override-username
Arne Schwabe [Wed, 2 Apr 2025 13:45:39 +0000 (15:45 +0200)] 
Use USER_PASS_LEN instead of TLS_USERNAME_LEN for override-username

Currently override-username is artificially restricted to the length of
TLS common-name (64) for the corner case of using username-as-common-name,
which we explicitly do not recommend to use.

Do away with that limitation and only error out on longer usernames when
username-as-common-name is actually in effect.

Change-Id: I1c2c050dd160746a0f8d9c234abe1e258bc8e48d
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20250402134546.3504-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg31323.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 months agoUse SSL_get0_peer_signature_name instead of SSL_get_peer_signature_nid
Arne Schwabe [Wed, 2 Apr 2025 15:33:28 +0000 (17:33 +0200)] 
Use SSL_get0_peer_signature_name instead of SSL_get_peer_signature_nid

SSL_get0_peer_signature_name returns a string instead of hardcoded NIDs.
NIDS do not work with provider provided signatures or the new PQ
signatures introduced in OpenSSL 3.5.

Remove also the comment that was added earlier that says that there
is no proper API replacement for SSL_get_peer_signature_nid yet as
OpenSSL 3.5.0 has now introduced it.

Change-Id: I2bc782ceebcc91a8dc8ada0bb72ac042be46cad6
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Antonio Quartulli <antonio@mandelbit.com>
Message-Id: <20250402153337.5262-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg31336.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 months agomanpage: fix HTML format for --local
Gianmarco De Gregori [Wed, 2 Apr 2025 14:08:51 +0000 (16:08 +0200)] 
manpage: fix HTML format for --local

Fix the HTML format for --local directive
to match the manpage structure.

Change-Id: I8d981a66932a5424ed959b12ee0cdddf881de91e
Signed-off-by: Gianmarco De Gregori <gianmarco@mandelbit.com>
Acked-by: Samuli Seppänen <sasepp@proton.me>
Message-Id: <20250402140901.18218-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg31321.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 months agoGHA: Make sure renovate notifies us about AWS LC releases
Frank Lichtenheld [Wed, 2 Apr 2025 15:36:55 +0000 (17:36 +0200)] 
GHA: Make sure renovate notifies us about AWS LC releases

Change-Id: I3434c35da75ede90a1b479b152142142ecc2fd40
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20250402153701.7560-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg31328.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 months agoFix FreeBSD-DCO and Multisocket interaction
Gianmarco De Gregori [Wed, 2 Apr 2025 13:21:42 +0000 (15:21 +0200)] 
Fix FreeBSD-DCO and Multisocket interaction

FreeBSD-DCO does not support TCP as transport protocol so in order to
be able to use DCO in a multi-socket environment we need to check the
local_list entries and disable DCO if any of the listening socket
is TCP.

While at it, removed some dead code left from Multisocket polishing.

Github: closes OpenVPN/openvpn#710

Change-Id: I9b6359076a61ae2bbb8e5cea00e33969cb5f92cf
Signed-off-by: Gianmarco De Gregori <gianmarco@mandelbit.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20250402132148.18810-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg31324.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 months agoAllow tls-crypt-v2 to be setup only on initial packet of a session
Arne Schwabe [Tue, 1 Apr 2025 17:30:37 +0000 (19:30 +0200)] 
Allow tls-crypt-v2 to be setup only on initial packet of a session

This fixes an internal server error condition that can be triggered by a
malicous authenticated client, a very unlucky corruption of packets in
transit or by an attacker that is able to inject a specially created
packet at the right time and is able to observe the traffic to construct
the packet.

The error condition results in an ASSERT statement being triggered,

NOTE: due to the security sensitive nature, this patch was prepared
under embargo on the security@openvpn.net mailing list, and thus has
no publically available "mailing list discussion before merge" URL.

CVE: 2025-2704
Change-Id: I07c1352204d308e5bde5f0b85e561a5dd0bc63c8
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <385d88f0-d7c9-4330-82ff-9f5931183afd@rfc2549.org>
Signed-off-by: Gert Doering <gert@greenie.muc.de>
4 months agodco-win: Fix crash when cancelling pending operation
Lev Stipakov [Tue, 1 Apr 2025 18:15:30 +0000 (20:15 +0200)] 
dco-win: Fix crash when cancelling pending operation

The OVERLAPPED structure must remain valid for the entire duration of an
asynchronous operation. Previously, when a TCP connection was pending
inside the NEW_PEER call, the OVERLAPPED structure was defined as a
local variable within dco_p2p_new_peer().

When CancelIo() was called later from close_tun_handle(), the OVERLAPPED
structure was already out of scope, resulting in undefined behavior and
stack corruption.

This fix moves the OVERLAPPED structure to the tuntap struct, ensuring
it remains valid throughout the operation's lifetime.

Github: closes OpenVPN/openvpn#715

Change-Id: Ib1db457c42a80f6b8fc0e3ceb4a895d4cf7f0155
Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20250401181535.7854-1-gert@greenie.muc.de>
URL: https://sourceforge.net/p/openvpn/mailman/message/59168247/
URL: https://gerrit.openvpn.net/c/openvpn/+/928
Signed-off-by: Gert Doering <gert@greenie.muc.de>
4 months agoGHA: Dependency and Actions update April 2025
Frank Lichtenheld [Mon, 31 Mar 2025 15:33:09 +0000 (17:33 +0200)] 
GHA: Dependency and Actions update April 2025

- Fix Android build with newer vcpkg
  Need to sync CMAKE_SYSTEM_VERSION with vcpkg.
- Update mbedTLS v3 builds to latest release.
  Depends on commit
  4897c522948c8cdb82c0325ee08f6907cfc16f57
- Update all actions to latest releases.

Change-Id: Ie9bffcc487f53a3a8ae6e59b79e654360d99902c
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Arne Schwabe <arne-openvpn@rfc2549.org>
Message-Id: <20250331153309.77901-1-frank@lichtenheld.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg31290.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
4 months agoGHA: Pin version of CMake for all builds
Frank Lichtenheld [Tue, 1 Apr 2025 17:04:14 +0000 (19:04 +0200)] 
GHA: Pin version of CMake for all builds

Turns out that "apt install cmake" is useless since
Github installs also CMake but not as a package. So
make sure we control which CMake we get and not
Github.

Switch to get-cmake action (which also installs ninja)
and remove the installation via apt.

Change-Id: Ief11d5d7ccae084c863b50054d4e97c71f57d6f0
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20250401170420.29808-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg31299.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
4 months agosocket: use remote proto when creating client sockets
Antonio Quartulli [Tue, 25 Mar 2025 10:57:24 +0000 (11:57 +0100)] 
socket: use remote proto when creating client sockets

When creating a socket to connect to a remote (this happens
in client mode) always use the protocol specified for the
remote.

The listening protocol in this case is just ignored as it
does not make any sense.

Change-Id: I6d2ec69ac7a9ef5900d8f1d8541d6a19c9cb7df9
Signed-off-by: Antonio Quartulli <antonio@mandelbit.com>
Acked-by: Arne Schwabe <arne-openvpn@rfc2549.org>
Message-Id: <20250325105724.1285-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg31234.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
4 months agoDo not leave half-initialised key wrap struct when dynamic tls-crypt fails
Arne Schwabe [Thu, 27 Mar 2025 15:36:00 +0000 (16:36 +0100)] 
Do not leave half-initialised key wrap struct when dynamic tls-crypt fails

In case when key_state_export_keying_material fails we left a
half-initialised tls_wrap_reneg  structure in the tls_session.
Later calls to try to free this structure causes freeing of
invalid memory locations.

To test: make key_state_export_keying_material return false even though
         HAVE_EXPORT_KEYING_MATERIAL is defined and connect to a server
         supporting dynamic tls-crypt (2.6.0+)

Change-Id: I54073f8b63894a62699f6ecdc90a77f9f131205b
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: MaxF <max@max-fillinger.net>
Message-Id: <20250327153606.15282-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg31267.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
4 months agot_server_null_default.rc: Add some tests with --data-ciphers
Frank Lichtenheld [Thu, 27 Mar 2025 09:47:00 +0000 (10:47 +0100)] 
t_server_null_default.rc: Add some tests with --data-ciphers

Trying to verify some of the negotiation parts.

Change-Id: I47d95eee8a00b9878331fd6cd6a7db12665f5537
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Samuli Seppänen <sasepp@proton.me>
Message-Id: <20250327094700.305156-1-frank@lichtenheld.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg31258.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
4 months agoFix compatibility with mbedTLS 2.28.10+ and 3.6.3+
Frank Lichtenheld [Thu, 27 Mar 2025 11:33:50 +0000 (12:33 +0100)] 
Fix compatibility with mbedTLS 2.28.10+ and 3.6.3+

From release notes:
In TLS clients, if mbedtls_ssl_set_hostname() has not been called,
mbedtls_ssl_handshake() now fails with
MBEDTLS_ERR_SSL_CERTIFICATE_VERIFICATION_WITHOUT_HOSTNAME
if certificate-based authentication of the server is attempted.
This is because authenticating a server without knowing what name
to expect is usually insecure. To restore the old behavior, either
call mbedtls_ssl_set_hostname() with NULL as the hostname [...]

Change-Id: I8bbb6ffdac7d0029dbf3c13e62c11b61813c15ef
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: MaxF <max@max-fillinger.net>
Message-Id: <20250327113356.11233-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg31262.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
4 months agoMention address if not unspecific on DNS failure
Arne Schwabe [Tue, 25 Mar 2025 19:57:43 +0000 (20:57 +0100)] 
Mention address if not unspecific on DNS failure

With the recent changes breaking configs that included lport 0, it became
apparent that having  the address family in the error message when
resolving fails, would have made diagnosis in this case and probably others
much easier.

Change-Id: I1c8fcd5bb6e1fa0020d52879eefbafdb2630e7b5
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20250325195750.7899-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg31237.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
4 months agoMake 'lport 0' no longer sufficient to do '--bind'.
Gert Doering [Mon, 24 Mar 2025 18:27:26 +0000 (19:27 +0100)] 
Make 'lport 0' no longer sufficient to do '--bind'.

'lport <anything>' used to trigger 'do socket bind', which is not
useful in itself for the 'lport 0' case (port 0 -> OS assigns a
random port, as it is done for unbound sockets) unless also binding
to a particular local IP address ('--local 192.0.2.1').

The trigger for 'lport has been used, do socket bind' is
ce.local_port_defined -> change the code to test for "0", and
only set this for non-0 ports (NOTE: this is a string match,
so if you really really want the old "lport 0" behaviour, using
"lport 00" still does that...).

The ce.local_port value is still set, so '--lport 0' together
with '--local 192.0.2.1' will give you a random port number
bound to that IP address - without 'lport 0' it would default
to 1194 or the value of '--port' (if not using '--rport').

Summary:  socket bind is now only done if one of these is set
  - --lport <port> with <port> not "0"
  - --bind  (default on the client is "--nobind")
  - --local <address>

Github: schwabe/ics-openvpn#1794

Change-Id: I1976307a7643c82f31d55ca32c79cbe64b6fffc6
Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Arne Schwabe <arne-openvpn@rfc2549.org>
Message-Id: <20250324182735.12657-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg31222.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
4 months agoImprove documentation for override-username
Arne Schwabe [Mon, 24 Mar 2025 13:54:33 +0000 (14:54 +0100)] 
Improve documentation for override-username

- Mention that pushing auth-token-user only happens when OpenVPN also
  generates the auth-token.
- mention that OpenVPN will only accept the original and overridden username
  from a client
- suggest to use auth-token-user when a user generates the auth-token

Change-Id: Ifc7443974345042ab9945d6a10e1d1b4525e5e05
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <20250324135441.26725-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg31210.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
4 months agoDirectly use _countof in array initialisation
Arne Schwabe [Mon, 24 Mar 2025 13:37:53 +0000 (14:37 +0100)] 
Directly use _countof in array initialisation

This fixes the build failures on MSVC cl compiler.

MSVC cl does not thinks of the expression of a const variable times
an integer to be compile time static. C23 introduce the constexpr
(like in C++) statement for that but we are only on C11 for now.

So directly use the _countof(msg->addr) expression in the array
initialisation.

Change-Id: Ib579c1538eb5440bb7008bc866a5cb7d74844374
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <20250324133759.13155-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg31205.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
4 months agowin: calculate address string buffer size
Heiko Hund [Mon, 24 Mar 2025 08:33:44 +0000 (09:33 +0100)] 
win: calculate address string buffer size

Instead of making the string buffer statically sized for a max. of
four addresses, calculate it to hold up to the max number of addresses
a dns_cfg_message_t can hold (currently four as well). Improves the code
so that it doesn't rely on the addresses never being more than four in
the future.

Change-Id: I23710b1f5b2122ec1f14465911836c0f0afa9c64
Signed-off-by: Heiko Hund <heiko@ist.eigentlich.net>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <20250324083350.4019-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg31196.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
4 months agoFix incorrect condition for checking password related check
Arne Schwabe [Sun, 23 Mar 2025 21:13:53 +0000 (22:13 +0100)] 
Fix incorrect condition for checking password related check

Commit db48cea chagned logic to move logic from a variable and repeated
checks to an if clause.

The old code had

            const bool ccnr = (options->auth_user_pass_verify_script
                                || PLUGIN_OPTION_LIST(options)
                                || MAN_CLIENT_AUTH_ENABLED(options));

followed by several condition that checked !ccnr

This commit fixes the if clause by correctly applying De Morgan's law.

Github: closes OpenVPN/openvpn#706

Change-Id: I28a8abd0ee3fa9168a716171b0a405476089c4a1
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Antonio Quartulli <antonio@mandelbit.com>
Message-Id: <20250323211359.14117-1-gert@greenie.muc.de>
URL: https://sourceforge.net/p/openvpn/mailman/message/59164222/
URL: http://gerrit.openvpn.net/c/openvpn/+/912
Signed-off-by: Gert Doering <gert@greenie.muc.de>
4 months agoPost tchar.h removal cleanup
Frank Lichtenheld [Wed, 19 Mar 2025 14:22:24 +0000 (15:22 +0100)] 
Post tchar.h removal cleanup

Remove some unused defines.

Change-Id: Ib3a166ead912beb2a591105c84d96d342664c05f
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20250319142234.25046-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg31172.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
4 months agoopenvpnserv: Clean up use of TEXT() from DNS patches
Frank Lichtenheld [Tue, 18 Mar 2025 17:39:06 +0000 (18:39 +0100)] 
openvpnserv: Clean up use of TEXT() from DNS patches

These are slightly different and so not covered
by my automatic conversion script. Use __func__
to make the actual string slightly shorter.

Change-Id: If15862fe537496ac836fc443936ff8e7876a39c0
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20250318173914.24425-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg31161.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
4 months agoApply text-removal.sh script to Windows codebase
Frank Lichtenheld [Tue, 18 Mar 2025 17:23:42 +0000 (18:23 +0100)] 
Apply text-removal.sh script to Windows codebase

Change-Id: I8f53c49b885c7c9e36a78ca434ec021e6dc347e0
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20250318172350.20996-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg31159.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
4 months agooptions: Cleanup and simplify options_postprocess_verify_ce
Frank Lichtenheld [Tue, 18 Mar 2025 15:53:11 +0000 (16:53 +0100)] 
options: Cleanup and simplify options_postprocess_verify_ce

- Reuse the MUST_BE_UNDEF macro in more places
- Add a second parameter so it actually reports the
  correct option name
- Add MUST_BE_FALSE for similar cases
- Reorder the checks for cert/key options to make
  more sense. Some of the checks could have never
  fired due to wrong placement of the management
  checks
- Some other small cleanups like missing spaces
  in multiline string literal

Change-Id: I4f766fa22865eaf4466c31cf55e3d73b00008c38
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20250318155320.32573-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg31155.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
4 months agodco: fix source IP selection when multihome
Qingfang Deng [Thu, 27 Feb 2025 03:25:22 +0000 (11:25 +0800)] 
dco: fix source IP selection when multihome

When multihome option is enabled, OpenVPN passes ipi_addr to DCO, which
is always 0.0.0.0. It should use ipi_spec_dst instead.

Signed-off-by: Qingfang Deng <dqfext@gmail.com>
Acked-by: Antonio Quartulli <a@unstable.cc>
Message-Id: <20250227032522.3734947-1-dqfext@gmail.com>
URL: https://sourceforge.net/p/openvpn/mailman/message/59154010/
Signed-off-by: Gert Doering <gert@greenie.muc.de>
4 months agodns: do not use netsh to set name server addresses
Heiko Hund [Wed, 12 Mar 2025 10:11:50 +0000 (11:11 +0100)] 
dns: do not use netsh to set name server addresses

Instead of spawning a netsh process, set the name server addresses
directly in the registry hive of the VPN interface.

This is a first step to get rid of the use of command line tools in the
service and move to a more API driven style of modifying the VPN adapter
configuration.

Change-Id: Id2bed0908e84c19b8fb6fe806376316793e550b4
Signed-off-by: Heiko Hund <heiko@ist.eigentlich.net>
Acked-by: Lev Stipakov <lstipakov@gmail.com>
Message-Id: <20250312101156.5756-1-gert@greenie.muc.de>
URL: https://sourceforge.net/p/openvpn/mailman/message/59159531/
URL: https://gerrit.openvpn.net/c/openvpn/+/825
Signed-off-by: Gert Doering <gert@greenie.muc.de>
4 months agodns: support multiple domains without DHCP
Heiko Hund [Wed, 12 Mar 2025 09:22:53 +0000 (10:22 +0100)] 
dns: support multiple domains without DHCP

Instead of using wmic on Windows to set one (the first) DNS domain,
modify the registry directly and let the resolver know that something
changed.

This fixes that more than one search domain suffix could only be applied
when DHCP and the tap driver was used. Now this works as well in netsh
mode with the interactive service.

If possible the search domains are stored with the rest of the VPN interface
parameter values. However, a global search list and one which is
distributed via group policy have priority (in that order), so we probe
for the existence of those first. In order to be able to restore the
original list in any case we store an "initial list" as a backup of the
search list before we modify it.

Github: closes OpenVPN/openvpn#642
Change-Id: Icaffbfa6b2e8efa2bd24a05537cb74b15f4fed96
Signed-off-by: Heiko Hund <heiko@ist.eigentlich.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20250312092259.26487-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg31108.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
4 months agoImplement override-username
Arne Schwabe [Tue, 11 Mar 2025 15:59:04 +0000 (16:59 +0100)] 
Implement override-username

This allow the server to set and override the username that is assumed
for the client for interaction with the client after the authentication.

This is especially intended to allow the of use auth-gen-token in
scenarios where the clients use certificates and multi-factor
authentication.

It allows a client to successfully roam to a different server and have
a correct username and auth-token that can be accepted by that server as
fully authenticated user without requiring MFA again.

The scenario that this feature is probably most useful
when --management-client-auth is in use as in this mode the OpenVPN
server can accept clients without username/password but still use
--auth-gen-token with username and password to accept auth-token as
alternative authentication. A client without a username will also not
use the pushed auth-token. So setting/pushing an auth-token-user
will ensure that the client has a username.

Github: OpenVPN/openvpn#299

Change-Id: Ia4095518d5e4447992a2974e0d7a159d79ba6b6f
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20250311155904.4446-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg31091.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
4 months agoRemove unused function check_subnet_conflict
Frank Lichtenheld [Sun, 9 Mar 2025 16:55:00 +0000 (17:55 +0100)] 
Remove unused function check_subnet_conflict

This has been #if 0 for over a decade. Let's just
remove this.

Change-Id: If570253e57371e4126b0e8aa4c349e2051cb8b00
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20250309165500.21796-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg31083.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
4 months agodco: pass remoteaddr only for UDP peers
Antonio Quartulli [Sun, 9 Mar 2025 15:30:17 +0000 (16:30 +0100)] 
dco: pass remoteaddr only for UDP peers

TCP connected sockets do not need any remote addr
because the destination is fixed.
For this reason we can avoid sending the remote addr
along the peer-new dco call.

This change is important on Linux because the new 'ovpn'
kernel module is stricter when it comes to accepting
netlink messages and will reject calls with TCP sockets
if a remote address is specified.

Change-Id: I76e2e616c6ffe436a9627fa71aaace74030b2f4a
Signed-off-by: Antonio Quartulli <antonio@mandelbit.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20250309153017.5163-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg31078.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
4 months agoRemove various unused function parameters
Frank Lichtenheld [Sat, 8 Mar 2025 10:04:55 +0000 (11:04 +0100)] 
Remove various unused function parameters

Change-Id: Ia3b0f22b0049a111ce52b3c87dd08a843ea9a919
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20250308100456.32383-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg31064.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
4 months agoAdd lwip support to t_server_null
Samuli Seppänen [Wed, 5 Mar 2025 13:46:42 +0000 (14:46 +0100)] 
Add lwip support to t_server_null

Change-Id: Ie63f302402f469c3aa48ac146ca6b8c029f0d250
Signed-off-by: Samuli Seppänen <samuli.seppanen@gmail.com>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <20250305134642.196598-1-frank@lichtenheld.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg31019.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
4 months agoHandle missing DCO peer by restarting the session
Ralf Lici [Wed, 5 Mar 2025 17:17:30 +0000 (18:17 +0100)] 
Handle missing DCO peer by restarting the session

Occasionally, CMD_DEL_PEER is not delivered to userspace, preventing the
openvpn process from registering the event. To handle this case, we
check if calls to the Linux DCO module return an error, and, if so, send
a SIGUSR1 signal to reset the session.

Most DCO commands that return an error already trigger a SIGUSR1 signal
or even call _exit(1). This commit extends that behavior to include
dco_get_peer_stats_multi() and dco_get_peer_stats().

Change-Id: Ib118426c5a69256894040c69856a4003d9f4637c
Signed-off-by: Ralf Lici <ralf@mandelbit.com>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <20250305171730.250444-1-frank@lichtenheld.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg31022.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
4 months agoRename occurences of 'struct link_socket' from 'ls' to 'sock'
Gianmarco De Gregori [Thu, 6 Mar 2025 10:13:39 +0000 (11:13 +0100)] 
Rename occurences of 'struct link_socket' from 'ls' to 'sock'

This commit renames all instances of 'struct link_socket'
from the abbreviation 'ls' to the more descriptive 'sock'
making it clearer that the variables represent
socket-related structures.

No functional changes have been introduced.

Change-Id: Iff12c4dbac84a814612aa8b5b89224be08bb9058
Signed-off-by: Gianmarco De Gregori <gianmarco@mandelbit.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20250306101339.12985-1-gert@greenie.muc.de>
URL: https://sourceforge.net/p/openvpn/mailman/message/59156800/
URL: https://gerrit.openvpn.net/c/openvpn/+/874
Signed-off-by: Gert Doering <gert@greenie.muc.de>
4 months agoAdd support for simultaneous use of UDP and TCP sockets
Gianmarco De Gregori [Thu, 6 Mar 2025 09:59:28 +0000 (10:59 +0100)] 
Add support for simultaneous use of UDP and TCP sockets

Add all the bound sockets to the event loop.
The main server loop has been updated to handle both
TCP and UDP connections.
The hash function has also been modified to include the
protocol during the creation of new client instances.
There are also a couple of refinements to make the
whole code flow management capable of handling
different kind of clients:

MULTI: properly remove TCP instances by checking the multi_instance
       protocol instead of the global one.

TLS: set the tls_option xmit_hold bool value to true only in case of
     TCP child instance to avoid checking the global protocol
     value.

INIT: initialize the c->c2.event_set in the inherit_context_top()
      by default and not only in case of UDP since we could have
      multiple different sockets.

Change-Id: I31bbf87e4e568021445c7512ecefadfd4a69b363
Signed-off-by: Gianmarco De Gregori <gianmarco@mandelbit.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20250306095928.10229-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg31028.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
4 months agoAdd more 'intentional fallthrough' comments
Frank Lichtenheld [Fri, 28 Feb 2025 17:02:32 +0000 (18:02 +0100)] 
Add more 'intentional fallthrough' comments

To make it easier to exclude them from compiler
warnings.

Based on the existing comment in init.c

Change-Id: I925accd8267f94ecfd9ccea85bae965dc2a10208
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Arne Schwabe <arne-openvpn@rfc2549.org>
Message-Id: <20250228170232.322186-1-frank@lichtenheld.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg30990.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 months agoGHA: Publish Doxygen documentation to Github Pages
Frank Lichtenheld [Fri, 28 Feb 2025 17:00:45 +0000 (18:00 +0100)] 
GHA: Publish Doxygen documentation to Github Pages

To make it more easily available to everyone.

Change-Id: I3922714972fffb3d7b1592f882d09c1fe1137241
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Yuriy Darnobyt <yura.uddr@gmail.com>
Message-Id: <20250228170045.321832-1-frank@lichtenheld.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg30989.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 months agodco-win: support for iroutes
Lev Stipakov [Thu, 20 Feb 2025 12:42:05 +0000 (13:42 +0100)] 
dco-win: support for iroutes

Unlike Linux/FreeBSD, dco-win doesn't have access to a
system routing table, so we have to maintain internal routing
table in the driver. For that, we have 4 ioctls to add/delete
IPv4/IPv6 iroutes. When adding iroute, we pass peer-id, so that
the driver is able to associate a subnet with a peer context.

Change-Id: I36a5442c0a5667628f419bc64efe5fb562ad3b57
Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20250220124205.27502-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg30958.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 months agoRemove x509-username-fields uppercasing
Corubba Smith [Sat, 15 Feb 2025 19:00:33 +0000 (20:00 +0100)] 
Remove x509-username-fields uppercasing

The uppercasing was first introduced together with the
x509-username-field option in commit 935c62be, and first released with
v2.2.0 in 2011. The uppercasing was later deprecated with commit
f4e0ad82 and release v2.4.0 in 2016. It think it is time to finally
remove it.

This deprecated feature prevents you from using non-extension
all-lowercase fieldnames like `name`, because these are converted to
uppercase and then cause an error. The deprecation warning is also shown
in cases where there is no actual uppercasing happening, for example
with numerical forms (aka oids) like `2.5.4.41` (oid of `name`).

Signed-off-by: Corubba Smith <corubba@gmx.de>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <cb8317eb-bfb6-47e8-9bc3-ae5cc603ff21@gmx.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg30915.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 months agoDocument x509-username-fields oid usage
Corubba Smith [Sat, 15 Feb 2025 19:01:44 +0000 (20:01 +0100)] 
Document x509-username-fields oid usage

When built against OpenSSL, the parameters of the x509-username-fields
option are in extract_x509_field_ssl() fed through OBJ_txt2obj() [0]
which accepts "long names and short names [...] as well as numerical
forms." Because of this, you can for example use `x509-username-field
2.5.4.41` to make OpenVPN read the `name` field [1].

x509-username-fields is currently not implemented for mbed TLS, so that
can be ignored.

[0] https://docs.openssl.org/1.1.1/man3/OBJ_nid2obj/
[1] https://oidref.com/2.5.4.41

Signed-off-by: Corubba Smith <corubba@gmx.de>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <eac80c73-e702-4d5c-b90a-fdaf4edd74f1@gmx.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg30916.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 months agodco-win: kernel notifications
Lev Stipakov [Thu, 20 Feb 2025 08:09:07 +0000 (09:09 +0100)] 
dco-win: kernel notifications

The driver supports notifications mechanism, which
is used to notify userspace about various events,
such as peer keepalive timeout, key expire and so on.

This uses existing framework of subscribing and
receiving dco notifications, used by FreeBSD and Linux
implementations. On Windows we use overlapped IO,
which state we keep in DCO context. We create an event,
which is associated with overlapped operation,
and inject it into openvpn event loop. When event is
signalled, we read overlapped result into DCO context,
which is later used by already existing code which
handles peer deletion.

Change-Id: Iedc10616225f6769c66d3c29d4a462b622ebbc6e
Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20250220080907.9298-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg30950.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 months agodco-win: simplify control packets prepend code
Lev Stipakov [Thu, 20 Feb 2025 07:43:27 +0000 (08:43 +0100)] 
dco-win: simplify control packets prepend code

Eliminate unneeded temporary struct sockaddr_in buffer.

Change-Id: Ie57f7b11157ab5ca8ff01e1c4f03a308117ff937
Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20250220074327.24922-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg30942.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 months agodco-win: multipeer support
Lev Stipakov [Wed, 19 Feb 2025 21:54:17 +0000 (22:54 +0100)] 
dco-win: multipeer support

This is the main commit for dco-win multipeer
implementation.

This adds concept of "mode" to DCO implementation,
which is peer-to-peer or multipeer. Depending on mode,
some functions use MP-specific IOCTL commands, which
include peer-id as a part of input.

The driver initialization accomodates server mode,
in which tun device is created before transport.

Since on Windows the socket is visible to the kernel only,
control channel packets have to be prepended with remote
sockaddr of the peer - this allows userspace to distinguish
among peers. Sadly there is no reliable way to get peer local
address, such as on Linux/FreeBSD, so we have to do a bit of
guesswork to figure out IP address based on remote IP and local
routing table, which may backfire if there are multiple IPs
assigned to the same network adapter. However, as for now
peer-specific local IP is not used by the driver. We use
instead the result of bind() to the listening address.

Existing sockethandle_finalize() function has been refactored
to accomodate packets with possibly prepended sockaddr.

Change-Id: Ia267276d61fa1425ba205f54ba6eb89021f32dba
Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20250219215417.18260-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg30935.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 months agoadd more (void) to windows specific function prototypes and declarations
Gert Doering [Wed, 19 Feb 2025 10:59:30 +0000 (11:59 +0100)] 
add more (void) to windows specific function prototypes and declarations

Change-Id: I1a9738ad73c79661a8beb4d9881eba0b4d3aea53
Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <20250219105930.29508-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg30929.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 months agoReconnect when TCP is on use on network-change management command
Arne Schwabe [Sat, 15 Feb 2025 15:24:56 +0000 (16:24 +0100)] 
Reconnect when TCP is on use on network-change management command

On some newer Android handsets, changing to a different network
often does not trigger a TCP reset but continues using the old
connection (e.g. using mobile connection when WiFi becomes available)

Force a reconnect in these situation to have a more expected beheaviour.

Change-Id: Id4febcceecab33ee5189cd67b249a15d12b84799
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20250215152456.5691-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg30908.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 months agoAdd android build to Github Actions
Arne Schwabe [Fri, 14 Feb 2025 16:06:34 +0000 (17:06 +0100)] 
Add android build to Github Actions

Change-Id: Ieb787a040f9eaf34d9d16996af1d63d7eae94944
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <20250214160634.6670-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg30900.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 months agoget_default_gateway(): Prevent passing IPV4_INVALID_ADDR as a destination
Marco Baffo [Fri, 14 Feb 2025 15:34:34 +0000 (16:34 +0100)] 
get_default_gateway(): Prevent passing IPV4_INVALID_ADDR as a destination

When using --redirect-gateway (IPv4) while connected to an IPv6 remote,
OpenVPN still attempts to determine the IPv4 default gateway,
so link_socket_current_remote() returns IPV4_INVALID_ADDR (0xffffffff)
as the destination, leading to unintended behavior:

- the IPv4 default gateway (rl->rgi.gateway.addr) gets wiped.
- this prevents proper restoration of the original route when needed.

To fix this, if link_socket_current_remote() returns IPV4_INVALID_ADDR,
we now pass INADDR_ANY (0x00000000) to get_default_gateway(),
ensuring the function behaves correctly.

Change-Id: I02afe6817433ca21aae76671c35151ec6a066933
Signed-off-by: Marco Baffo <marco@mandelbit.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20250214153434.18539-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg30895.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 months agoAdd (fake) Android cmake building
Arne Schwabe [Fri, 14 Feb 2025 12:52:38 +0000 (13:52 +0100)] 
Add (fake) Android cmake building

There is a mode to build with a real Android NDK that requires setting
up cmake to build with the NDK and so.
For quick&dirty compile tests that do not actually use the Android NDK
on Linux, -DFAKE_ANDROID on Linux can be used to compile a binary using
TARGET_ANDROID.

Change-Id: If6afa1108f9234f98afdbe0de7b7320403871772
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <20250214125238.17558-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg30885.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 months agoGHA: Drop Ubuntu 20.04 and other maintenance
Frank Lichtenheld [Wed, 12 Feb 2025 21:51:51 +0000 (22:51 +0100)] 
GHA: Drop Ubuntu 20.04 and other maintenance

- Drop Ubuntu 20.04
  GHA runners will go away in April 2025
- Change ubuntu-latest to ubuntu-24.04
  to make sure we are not surprised by
  future changes.
- Update vcpkg digest to latest 33e9c99
- Update github actions to latest

Change-Id: I29b68675143988c3304395d9d5ec62289cf519a7
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Yuriy Darnobyt <yura.uddr@gmail.com>
Message-Id: <20250212215151.619-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg30852.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 months agoExtend the unit test for data channel packets with aead limit tests
Arne Schwabe [Thu, 13 Feb 2025 19:39:41 +0000 (20:39 +0100)] 
Extend the unit test for data channel packets with aead limit tests

Change-Id: I15c7cfdddb06d4530d669b222a3c65db5169b29a
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: MaxF <max@max-fillinger.net>
Message-Id: <20250213193942.26423-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg30864.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 months agoImplement epoch key data format
Arne Schwabe [Wed, 12 Feb 2025 16:13:11 +0000 (17:13 +0100)] 
Implement epoch key data format

With DCO and possible future hardware assisted OpenVPN acceleration we
are approaching the point where 32 bit IVs are not cutting it any more,
especially if we are limiting the IVs to the safe limits of AES-GCM where
the limit is more 2^29.

To illustrate the problem, some back of the envelope math here:

If we want to keep the current 3600s renegotiation interval and have
a safety margin of 25% (when we trigger renegotiation) we have about
3.2 million packets (2*32 * 0.7) to work with. That translates to
about 835k packets per second. Currently, implementation trigger the
renegotiation at 0xff00000000 or at 7/8 of the AEAD usage limit.

With 1300 Byte packets that translates into 8-9 Gbit/s. That is far
from unrealistic any more. Current DCO implementations are already in
spitting distance to that or might even reach (for a single client
connection) that if you have extremely fast
single core performance CPU.

With the AEAD usage limit, these limits are almost a factor of 8 lower
so with the limit becomes 1-2 GBit/s. This is already reached without
DCO on some platforms.

This introduces the epoch data format for AEAD data channel
ciphers in TLS mode ciphers. No effort has been made to support
larger packet counters in any other scenario since those are all legacy.
This uses the same approach of epoch keys as (D)TLS 1.3 does and switches
the data channel regularly for affected AEAD ciphers when reaching the
usage limit.

For Chacha20-Poly1305, which does not suffer the same problems as AES-GCM,
the full 48 bit of packet counter are used only after that the same logic
to switch to a new key as with AES-GCM is done.

Change-Id: I00751c42cb04e30205ba8e6584530831e0d143c5
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: MaxF <max@max-fillinger.net>
Message-Id: <20250212161311.16888-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg30845.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 months agoFix oversight of link socket code change in Android code path
Arne Schwabe [Wed, 12 Feb 2025 12:38:20 +0000 (13:38 +0100)] 
Fix oversight of link socket code change in Android code path

Commit 94b391d7ef5 changed context->link_socket to context->link_sockets
but did not change the Android code path.

Change-Id: If6a636b2099d948e249cf92ed2ba91d1698ee42f
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20250212123820.19099-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg30833.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 months agoFix typo in positive_atoi
Arne Schwabe [Wed, 12 Feb 2025 12:36:52 +0000 (13:36 +0100)] 
Fix typo in positive_atoi

This is a code path that only affects Android

Change-Id: I3f05318fb6f8d9e32d07532a4f0c6ccf8fb757ce
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20250212123652.18183-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg30832.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 months agoadd missing (void) to win32 function declarations
Gert Doering [Wed, 5 Feb 2025 17:02:32 +0000 (18:02 +0100)] 
add missing (void) to win32 function declarations

mingw complains about "old-style function definition" and since we
use explicit (void) everyhwere else...

Change-Id: I59e34058d6e0611208767fbcf39d1b91784ebcf9
Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <20250205170232.3473-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg30813.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 months agodco-win: disable dco in server mode if multiple --local options defined
Lev Stipakov [Wed, 5 Feb 2025 12:23:41 +0000 (13:23 +0100)] 
dco-win: disable dco in server mode if multiple --local options defined

dco-win doesn't yet support multisocket, so for the time
being we have to fallback to tap-windows6.

Change-Id: I8724eda269b816dd2cfd0833d467e6d24054e96f
Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20250205122341.4944-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg30805.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 months agoAdding AWS-LC to the OpenVPN CI
Shubham Mittal [Fri, 31 Jan 2025 20:57:27 +0000 (12:57 -0800)] 
Adding AWS-LC to the OpenVPN CI

Github: closes OpenVPN/openvpn#673
Signed-off-by: Shubham Mittal <smittals@amazon.com>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20250131205727.60957-1-smittals@amazon.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg30776.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 months agomulti.c: add iroutes after dco peer is added
Lev Stipakov [Sat, 1 Feb 2025 12:11:02 +0000 (13:11 +0100)] 
multi.c: add iroutes after dco peer is added

This doesn't matter for Linux and FreeBSD but matters
for dco-win, where iroute subnet is mapped to a peer
context, which means that peer has to be created before
iroute is added.

Change-Id: I1cac0f036504c87205a3c97589a94a662cf79b99
Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20250201121102.27395-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg30780.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 months agoImprove error reporting from AF_UNIX tun/tap support
Arne Schwabe [Sat, 1 Feb 2025 12:20:06 +0000 (13:20 +0100)] 
Improve error reporting from AF_UNIX tun/tap support

When having a non-existent lwipovpn binary or similar problems, the
error reporting would often only report read error that were harder to
identify the real problem.  Add the openvpn_waitpid_check method
that checks for error conditions and reports a better message in cases
of problems.

Change-Id: I81cbecd19018290d85c6c77fba7769f040d66233
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20250201122006.32098-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg30782.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 months agomudp.c: keep offset value when resetting buffer
Lev Stipakov [Tue, 21 Jan 2025 16:10:25 +0000 (17:10 +0100)] 
mudp.c: keep offset value when resetting buffer

dco-win requires control packets to be prepended
with sockaddr. For that, an offset value in buffer
must be kept. Doing it always doesn't harm and makes
code cleaner compared to adding "if (dco_win_server)"
condition.

Change-Id: I145573555aaace5e94774b5f977d032d3747ed72
Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <20250121161025.37545-1-frank@lichtenheld.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg30519.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 months agoroute.c: improve get_default_gateway() logic on Windows
Lev Stipakov [Fri, 31 Jan 2025 15:41:35 +0000 (16:41 +0100)] 
route.c: improve get_default_gateway() logic on Windows

When adding host route for IPv4, we use the default gateway. There are
cases, however, when this does not work - for example when remote
is not accessible via default gateway but via dedicated route.

Factor out code to look for the best gateway to reach the host from
get_default_gateway_ipv6() and generalize is for IPv4/6.

Change-Id: I6c7e1cef637fe9fb3f3bc6ff4fb2c65599cd86fb
Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20250131154135.32169-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg30769.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 months agoget_default_gateway(): implement platform support for Linux/IPROUTE2
Gert Doering [Fri, 31 Jan 2025 08:47:07 +0000 (09:47 +0100)] 
get_default_gateway(): implement platform support for Linux/IPROUTE2

Remove the old "read /proc/net/route and try to parse it" implementation
and always use the sitnl/netlink implementation of net_route_v4_best_gw().

This was kept "because we had it and it was working" but does not really
provide any benefit - netlink for route queries is there for v6 anyway,
and the main argument for keeping --enable-iproute2 is "some users want
to run non-standard 'ip' binaries to do things" - which is not affected
by this change.

Change-Id: I6f17140109106b37e6b0e690df1d87720ccf6f91
Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Antonio Quartulli <a@unstable.cc>
Message-Id: <20250131084707.24905-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg30748.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 months agoget_default_gateway(): implement platform support for Linux/SITNL
Gert Doering [Fri, 31 Jan 2025 08:46:51 +0000 (09:46 +0100)] 
get_default_gateway(): implement platform support for Linux/SITNL

This adds Linux/SITNL platform functionality to the framework started by
commit 9df51cf56 and commit 0fcfc8381f.

v2: make comment reflect reality

Change-Id: I1db72d7dca648a8ea4ec65d173290a819971305c
Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Antonio Quartulli <a@unstable.cc>
Message-Id: <20250131084651.24765-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg30749.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
6 months agooptions: add IPv4 support to '--show-gateway <arg>'
Gert Doering [Wed, 29 Jan 2025 17:30:07 +0000 (18:30 +0100)] 
options: add IPv4 support to '--show-gateway <arg>'

This is an old debug option, which used to print "the default routes found"
for IPv4 and IPv6, and optionally "a route to a particular IPv6 target"
if passed an argument.

With the work started in commit 0fcfc8381f60d we want this to handle
IPv4 as well, mostly to be able to easily test per-platform
get_default_gateway() implementations.

The implementation is simplistic - if <arg> can be parsed as an IPv4 or
IPv6 address, that particular protocol lookup will do "the host route"
and the other one will stick to "the default route".

NOTE: as of this commit, there is no backend functionality for IPv4, so
it will not actually print anything interesting.  This will be added in
further platform dependent commits.

v2: amend --help output
v3: uncrustify (#ifdef block too long, comments at #endif required now)

Change-Id: Ic438c583a782035ecb9b5ea65702a768ae2585f5
Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Lev Stipakov <lstipakov@gmail.com>
Message-Id: <20250129173007.3280-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg30728.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
6 months agoFix doxygen warnings in crypto_epoch.h
Frank Lichtenheld [Wed, 29 Jan 2025 18:28:18 +0000 (19:28 +0100)] 
Fix doxygen warnings in crypto_epoch.h

Introduced by commit 92adbc88b1b37095cebde2a1c5b6ae242f382678.

Change-Id: I0133085ac68f7b0db574b88276f6d5e1d3ad62d5
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Arne Schwabe <arne-openvpn@rfc2549.org>
Message-Id: <20250129182818.3041-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg30731.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>