236 Commits

Author SHA1 Message Date
Lev Stipakov
e34094e30d Refactor reauthentication logic
The reauthentication logic differs from openvpn2
and the code is a bit hard to follow. Simplify
the code and make it behave like in openvpn2.

 - password is cached by default

 - password is purged when auth-nocache is presented in a local config or pushed

 - when AUTH_FAILED is received and we have no session-id, throw a fatal error

 - when AUTH_FAILED is received and user interaction is required for
   authentication (MFA), throw a fatal error

 - when AUTH_FAILED is received, user interaction is not required
   for authentication and either we have a cached password OR password is not
   needed, we reconnect.

Password is "needed" when non-empty password is provided.

User interaction is required for static/dynamic challenge and SAML.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2024-05-08 16:39:24 +00:00
David Sommerseth
149ec03864 Merge OpenVPN 3 Core library version 3.8.5 to master
Signed-off-by: David Sommerseth <davids@openvpn.net>
2024-05-03 14:50:21 +02:00
Arne Schwabe
dc35bd8d07 Replacing logging in ssl context und proto context with new logger
This allows the test_proto.cpp to supress all the logging of this
class. This is also the only place in our project that actually uses
a non-default loglevel for this class. A lot of files were defining the
OPENVPN_LOG_SSL(x) macro to be what the also remove ssllog.hpp would do
anyway if it were not defined.

The removed debug_level field  only controlled the mssfix
logging and is now controlled by the general protocol logging instead.

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2024-04-17 14:48:50 +00:00
Lev Stipakov
4f1f22159f Improve handling of unknown options
A few minor changes:

 - add ORGANIZATION meta option to ignore list

 - remove excessive OVPN_ACCESS_SERVER_ prefix from NO_WEB meta option

 - Increase status message length from 256 to 2048 to be able to show
   the full list of unsupported options

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2024-03-22 21:25:48 +01:00
Frank Lichtenheld
61c0ab7f6b client: Switch to UseSWIG instead of manual custom command
On modern CMake this gets us swig dependency management,
which should reduce problems for incremental builds.
Also it is just cleaner.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
(cherry picked from commit 72275db1d5)
2024-03-07 00:29:36 +02:00
Frank Lichtenheld
ef3b290de6 CMake: replace FindPythonIntp with FindPython3
The earlier were deprecated since CMake 3.12.
Since CMake 3.27 this causes deprecation warnings.
Should be safe nowadays to require CMake 3.12.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
(cherry picked from commit bb61350ae5)
2024-03-07 00:29:36 +02:00
Frank Lichtenheld
8c007de79d client: Explicitely use int as socket type in SWIG
For some reason SWIG doesn't seem to pick this
up automatically from the typedefs.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2024-03-06 13:00:04 +01:00
David Sommerseth
bae10062b3 Merging in changes from OpenVPN 3 Core version 3.8.4
Signed-off-by: David Sommerseth <davids@openvpn.net>
2024-02-19 22:46:53 +01:00
Lev Stipakov
b4a400f6fe Improve handling of unknown options
Currently we error out on the first unsupported
option which belongs to the "fatal" category, such as
"removed deprecated option" or "Option allowed only to
be pushed by the server".

To improve user experice and allow application code
to display all problematic options and their categories,
collect options into a category->options map and then
serialize it into multiline string:

  cat1: opt1,opt2
  cat2: opt3

Introduce a new error code UNUSED_OPTIONS, which is
placed into ClientAPI::Status::status. The serialized
options map is placed into ClientAPI::Status::message.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2024-02-07 17:03:45 +02:00
Arne Schwabe
f1ac7e500f Allow a client to announce custom control channel support
Signed-off-by: Arne Schwabe <arne@openvpn.net>
2023-12-13 16:51:22 +01:00
Arne Schwabe
e9ade86de7 Implement logic to send and receive custom control channel messages
This adds the capability to implement a custom app level protocol
that support message passing over the OpenVPN control channel.
The protocol is agnostic to the data that is transported over it
and the message splitting/reassmbly is handled transparently by the
OpenVPN library itself.

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2023-12-13 16:51:22 +01:00
Frank Lichtenheld
72275db1d5 client: Switch to UseSWIG instead of manual custom command
On modern CMake this gets us swig dependency management,
which should reduce problems for incremental builds.
Also it is just cleaner.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2023-11-08 21:10:19 +01:00
Frank Lichtenheld
8f7fdd10ff Use openvpn_io::detail::socket_type instead of "int"
On Linux those might be identical, but not on Windows.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2023-09-28 11:33:41 +02:00
Arne Schwabe
ff80eca4e5 Rename ProtoContextOptions to ProtoContextCompressOptions
This might have been used or intended to be used for more than compression
but currently it is only used for compression, so rename it accordingly.

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2023-08-23 21:13:01 +02:00
Frank Lichtenheld
bb61350ae5 CMake: replace FindPythonIntp with FindPython3
The earlier were deprecated since CMake 3.12.
Since CMake 3.27 this causes deprecation warnings.
Should be safe nowadays to require CMake 3.12.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2023-08-02 18:08:42 +02:00
Arne Schwabe
75dbf4b5d2 Rename generate_tun_builder_capture_event to camelcase
This makes this option have the same style as the other options in
the client config to ensure consistencyv

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2023-07-25 12:00:48 +02:00
Frank Lichtenheld
6585480389 ConfigCommon: do not include actual profile
This is not required in ClientConfigParsed, and actually makes
the object significantly bigger, due to the contained certificates.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Signed-off-by: Arne Schwabe <arne@openvpn.net>
2023-07-25 12:00:48 +02:00
Arne Schwabe
0c5e356075 Simplify client options classes
The current passing of client options is very confusing since it is
three classes that largely have the same attributes and the code is
copying them around between the classes.

Instead create a new base class that hold the settings that can be shared
between the classes and only parse/copy the settings that need special
handling. This might keep an extra copy of some settings around but in
constract greatly reduces the code complexity of the options handling.

Also move the check_dco_compatibility function to client options to
be able to avoid carrying around the dco_compatiblity flag.

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2023-07-25 12:00:48 +02:00
Lev Stipakov
84cf8f45cd dco: check for options/config DCO compatibility
When parsing config, check DCO compatibility. Following
options break DCO compatibility:

 - http-proxy
 - compress
 - comp-lzo

Same for config settings:

 - non-preferred-algorithms
 - legacy-algorithms
 - proxyHost

DCO compatibility could be checked with

 - bool EvalConfig::dcoCompatible
 - std::string dcoIncompatibilityReason

If client nevertheless tries to connect, an exception
will be thrown:

  connect error: option_error: dco_compatibility: config/options are not
compatible with dco

Fixes OVPN3-960.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2023-05-08 13:51:34 +03:00
Arne Schwabe
48f5adce94 Ensure that tlsVersionMinOverride does not lower TLS version
This ensure that client that want to set a miminum level of TLS
version do not accidentially lower the version when the profile already
requires a higher version.

Also make the tls version enum an enum class for better type safety.

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2023-03-29 23:14:15 +02:00
David Sommerseth
dde1574596 Reformatting source code to new coding style
This is the result after running 'clang-format -i' on all C++ files and
headers, with the defined formatting rules in .clang-format.

Only the openvpn/common/unicode-impl.hpp has been excluded, as that is
mostly a copy of an external project.

Signed-off-by: David Sommerseth <davids@openvpn.net>
2023-01-18 19:24:15 +01:00
David Sommerseth
4996c38ed4 Merge lastest changes from Core v3.7.2 2022-12-14 17:34:29 +01:00
Arne Schwabe
aa3bcb8b3a Fix route emulation not correctly working and being disabled
Signed-off-by: Arne Schwabe <arne@openvpn.net>
2022-12-14 17:23:13 +01:00
David Sommerseth
8c94a8f774 copyright: Update to 2022
Signed-off-by: David Sommerseth <davids@openvpn.net>
2022-09-29 12:00:26 +02:00
Arne Schwabe
26fad3a4f6 Allow to disable route exclusion emulation
This allows disabling the route emulation for Andorid API 33
(Tiramisu/API 33) or if the app implements its own emulation (ics-openvpn)

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2022-08-03 16:41:06 +02:00
Arne Schwabe
3710fa106a Implement pushable tun-mtu and tls-mtu-max
OpenVPN 3.x has the same approach/problem for buffer allocation for the
tunnel packets that OpenVPN 2.x uses. Buffers are allocated very early
in the setup, so resizing/reacting to different frame sizes is not
really possible without major refactoring.

Therefore we use the same approach as with OpenVPN 2.x and allow a
MTU of up to 1600 by default and require setting tun-mtu-max in the
configuration file to allow larger values and allocate larger buffers.

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2022-07-13 16:44:31 +02:00
Arne Schwabe
811c8c78ca Use xkey provider for external keys with OpenSSL 3.0
The xkey provider has been originally implemented by Selva Nair for
OpenVPN 2.x and he has agreed to allow me to reuse the provider for
OpenSSL 3.0

This brings the xkey provider to OpenSSL to Openvpn3. The xkey_provider.c
file is kept as close as possible to the original OpenVPN 2 source.
From xkey_helper only the parts that were needed were picked up and used
in xkey.hpp.

This also changes the requests for clients wanting to implementing the
API, generally making them more work (adding PSS/PKCS1 padding and hashing)
but this is a good thing since especially external keys/HSM often do not
like doing raw signatures and often require to do padding/hashing themselves.

This commit also updates the test client's EPKI implementation to work
with the new requirements of the new API.

Since most of OpenVPN3's code base assumes having only one compilation unit
and the xkey_provider.c, this commit introduces the ENABLE_EXTERNAL_PKI
define. Only if this is set external key support is supported (and the
xkey_provider.c compilation unit needed).

This commit furthermore removes the pragma statements from extpki.hpp that
supressed warnings when being compiled with OpenSSL 3.0+ as this is header file
longer compiled with OpenSSL 3.0+. (Technically xkey is >= 3.0.1 but we have
no target that is OpenSSL 3.0.0).

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2022-06-08 22:41:36 +02:00
James Yonan
085836cea9 ovpn3 client: support a new client event containing the data from TunBuilderCapture::to_json()
The event is of type INFO_JSON and is formatted:

  TUN_BUILDER_CAPTURE:{...}

This info is useful to determine the properties of a
VPN client session such as VPN IPs, Gateway IPs,
and DNS resolvers, and can be directly used as
a VPN Connection Profile.

This patch also adds the

  cli --tbc <file>

option to write the TunBuilderCapture JSON to a file.

Signed-off-by: James Yonan <james@openvpn.net>
2022-05-13 19:09:09 -06:00
Frank Lichtenheld
dc328c2ab2 ovpncli: Fix unitialized class member
CID 10065 (#6 of 6): Uninitialized scalar field (UNINIT_CTOR)
2. uninit_member: Non-static class member proto_version_override
is not initialized in this constructor nor in any functions that it calls.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2022-03-21 15:50:09 +01:00
Frank Lichtenheld
592b6c4604 cmake: create findswigdeps to reduce code duplication
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2022-03-16 13:02:19 +01:00
Lev Stipakov
77b0bae736 client/CMakeLists.txt: build swig library only on Windows x64 arch
Swig library build uses Python library which has the the same arch
as build machine arch, which in our case is always x64.

Building for other archs causes machine type conflicts.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2022-03-16 11:56:09 +01:00
Lev Stipakov
70d0f23305 client/CMakeLists.txt: don't use gcc-specific flags in Windows build
Commit 9ad98bae8f ("Add building ovpncli swig library to cmake build")
added GCC-specific compiler flags which are unknown on Windows.

Remove those flags from Windows build.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2022-03-16 11:56:09 +01:00
Frank Lichtenheld
5f12014ca1 client: Fix build with SWIG 3.0 and new GCC
We saw problems with this on our RHEL7 builds because
we upgraded gcc but not swig. Work-around the issue
for now until we can require SWIG 4.0.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2022-03-11 18:51:10 +01:00
David Sommerseth
81441e8fa1 Merge OpenVPN 3 Core library version 3.6.6 changes 2022-03-11 00:16:55 +01:00
Frank Lichtenheld
f3f6f580b3 ovpncli: fix uninitialied value in config_templ (CID 11125)
CID 11125 (#1 of 1): Uninitialized scalar variable (UNINIT)
8. uninit_use_in_call: Using uninitialized value
config_templ.enableNonPreferredDCAlgorithms when calling Config.
flood.cpp:1320

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2022-02-21 13:23:06 +01:00
Arne Schwabe
39443bff46 Rename enableNonPreferredDCOAlgorithms to config.enableNonPreferredDCAlgorithms
This should be DC for data channel instead DCO for data channel offload.

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2022-01-12 18:30:06 +01:00
Arne Schwabe
d0a9b61b4b Do not allow SWEET32 vulnerable algorithms and MD4 without enableLegacyAlgorithm
With OpenSSL3, these algorithms are no longer allowed. With this change
we do the same regardless of the crypto library. Note that in contrast
to OpenSSL3, we include here 3DES into the legacy algorithms.

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2022-01-12 18:30:04 +01:00
Arne Schwabe
9ad98bae8f Add building ovpncli swig library to cmake build
This also moves ovpncli.i to a proper place
2021-12-15 13:05:14 +01:00
Arne Schwabe
d7b316bd11 Move helper function from OpenVPNClient int OpenVPNClientHelper
This also makes most of them non-static to avoid the problem that these
functions depend on Initprocess::Init being instantiated before being
called.

Rename the local variables eval to eval_cfg to avoid shadowing the
class field of the same name.
2021-12-15 13:03:41 +01:00
Arne Schwabe
d583aee26c Remove OpenVPNClient::app_expire() functionality
Early client seemed to have an inbuilt expire date. But that
functionality is no longer used and can be removed.
2021-12-15 13:03:19 +01:00
Arne Schwabe
3f90304154 Allow controlling usage of non preferred DC ciphers via option
Signed-off-by: Arne Schwabe <arne@openvpn.net>
2021-11-12 20:58:46 +01:00
Arne Schwabe
847f8da3ee Remove some leftover forceAesCbcCiphersuites code
This feature was removed a while ago and these settings do not do
anything any more.

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2021-11-12 20:58:45 +01:00
Arne Schwabe
aee55f307b [OSSL 3.0] Add unit test to test that legacy provider loading works
Signed-off-by: Arne Schwabe <arne@openvpn.net>
2021-11-12 20:58:40 +01:00
Arne Schwabe
1b5d913503 Implement setting legacy provider from ovpncli.cpp/test client
Signed-off-by: Arne Schwabe <arne@openvpn.net>
2021-11-12 20:58:38 +01:00
Arne Schwabe
88b2906a2c Rework block-ipv6 to also allow blocking ipv4 and remove IV_IPV6
Since IPv4/IPv6 should be treated equally, we should have also
the opportunity to block IPv4. With this change we follow the API
that also Android provides and expliticly tell tunbuilder what to
do with address families that are not used by the VPN. If a
address family is used by the VPN, nothing changes.

This also remove IV_IPV6 as it is not used.
2021-10-27 20:15:26 +02:00
Lev Stipakov
fd0655969d Merge release of OpenVPN Core library 3.6.4 to master 2021-09-22 13:56:37 +02:00
Lev Stipakov
613aa6bf7a Win: support for local DNS resolvers
Local DNS resolvers, such as Umbrella Roaming Client,
change DNS settings on adapters to 127.0.0.1.

This may not work with openvpn3 because:

 - NRPT rule might be created for "." zone,
which redirects all DNS requests to the server
specified in rule. This takes precendence over adapters'
DNS settings.

 - DNS requests might be blocked on all adapters
except TAP (tap-windows6/wintun/ovpn-dco-win) to prevent
DNS leaks.

To enable compatibility with local DNS resolvers, add
"allowLocalDnsResolvers" core config option, which,
when enabled, makes core to

 - avoid creating NRPT rule for "." zone

 - permit DNS requests to 127.0.0.1 / ::1

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2021-08-10 15:00:58 +03:00
Arne Schwabe
98f5b59a07 Document WEBAUTH and implement it as auth pending method in demo client
Signed-off-by: Arne Schwabe <arne@openvpn.net>
2021-07-28 14:50:06 +02:00
Antonio Quartulli
4fa0d6763e ovpncli.cpp: update stats with DCO data before querying them
Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2021-06-08 01:42:37 +02:00
Heiko Hund
51bd6d4201 use DCO opportunistically
If DCO support is compiled in, detect if it is available (i.e. Windows driver
or Linux kernel module is loaded) and then use it, if it is.

This changes the default configuration for DCO from off to on, so users of
the library need to set ClientAPI::Config::dco to false in case they do not
want to use dco for a connection.

The change is also reflected in the reference client "ovpncli". If DCO is
enabled in a build, it will detect and use it. The previously available
"ovpncliovpndco" and "ovpncliovpndcowin" clients have thus been removed.

Signed-off-by: Heiko Hund <heiko@openvpn.net>
2021-05-27 17:20:24 +02:00