0
0
mirror of https://github.com/OpenVPN/openvpn3.git synced 2024-09-20 04:02:15 +02:00
Commit Graph

219 Commits

Author SHA1 Message Date
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
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 OpenVPN 3 Core library version 3.6.6
-----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64iQlU6ZzaQ
 EkG9PSQvddwK5wxOLMaorG2PvFZmPTyBd0HoQUE9l1OiW3dgWu9sKK5Nm+Zgh4o5
 8KA/4f2AOxkXY/PkHylOcGPz8zevXJ1sHoJCXMNd3vWmpJ8jLoEQpX5qsMZcJhNn
 Q8ArRTI3OUrBXK4AkgCoJO2Gf83S+ROzZMNGVlJayW/7qjNXKGR0F1RQnEbaj2me
 bawYa7rZQ0sl9sHW87QEW6QgCrMu1SbaQFvNFJzhhm1UpBLPbcFaTVl/j265ndtQ
 34WblEePQMuCMKHxMP0EvYcz9eRIXQgPgXGCa4IOletD2te4LuAyyoPphAbntCi4
 gb54byMcoeOUgcRNBC9VuKI3SBwSUMh2o2VazZuo7gNk7PYpM7lTPLTylTeu37/9
 H/Dg1Z/M31FhSE7wCh+JwtWDnpKalwhQYSU4ugXqJ4DquwH043ZmrZoTKucixWHy
 VhNbrBgqQdnb2bJLMTII1J4khsjnh2pAWIuBiekpAtGNef8CVi77OX9YeX/z/R3w
 6WZZrvGoePLdabXhESfNpzvNM9PgqGqgWKhQBs6oj9gA7I2uKEUXMyxm33AJIuV5
 CHOSjo6kpWN7Fw==
 =ONLf
 -----END PGP SIGNATURE-----

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
Heiko Hund
77cf3a10c5 initialize allow_local_lan_access member
Signed-off-by: Heiko Hund <heiko@openvpn.net>
2021-05-18 06:13:31 +02:00
Heiko Hund
e2d252ef4a
add API to override IP protocol version
The new element ClientAPI::Config::protoVersionOverride can be set
to 4 or 6 respectively, to override the transport protocol IP version
used by RemoteList::Item entries. Clients can force all --remotes
to use IPv4 or IPv6 using this entry, if they know that only one of
the two is available in the current network.

Signed-off-by: Heiko Hund <heiko@openvpn.net>
2021-05-05 19:46:58 +02:00
Heiko Hund
1e55fdadf1
make it possible to provide HTTP proxy creds
Extend struct ProvideCreds so that it can also hold HTTP proxy
credentials. This makes it possible to use proxy settings from
options, but provide credentials separately.

This is in contrast to the already existing struct Config::proxy*
which need to be given as a complete set to override eventual
HTTP proxy options.

Signed-off-by: Heiko Hund <heiko@openvpn.net>
2021-04-14 22:40:09 +02:00
Arne Schwabe
012e7e8226
Refactor InitProcess to use refcounting
Although the init calls were protected by a mutex more than consumer of
the API will the second one if the uninit was called too early.

While at it, move from explicit init/uninit calls to RAII.

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2020-09-02 20:37:01 +02:00
David Sommerseth
ca61dd97db
Merge support for --redirect-gateway local from released 2020-09-02 20:35:47 +02:00
Lev Stipakov
3761f2ff89 ovpn-dco: initial support
Add tun/transport client skeleton for ovpn-dco,
which doesn't do any work except creating/removing
ovpn-dco device.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2020-08-26 10:53:27 +00:00
Lev Stipakov
123865356d rename ENABLE_DCO to ENABLE_KOVPN
As a preparation for ovpn-dco support.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2020-08-26 10:53:27 +00:00
Lev Stipakov
7193de12ab
Support for redirect-gw local
When VPN server is in local network and
not accessible via default gateway, adding bypass route
via default gw (as we do on windows/mac) makes server
inaccessible.

This handles client-side config option "redirect-gw local"
and skips adding bypass route via agent.

Fixes OVPN3-653

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2020-08-11 11:42:05 +03:00
David Sommerseth
3fbe0a2701
Update copyrights
Signed-off-by: David Sommerseth <davids@openvpn.net>
2020-03-18 19:37:32 +01:00
Arne Schwabe
6e463ca1f4
Implement tls-cipher and tls-ciphersuite
Signed-off-by: Arne Schwabe <arne@openvpn.net>
2020-03-11 19:51:37 +01:00
Arne Schwabe
9c547ba3ff
Remove force_aes_cbc_ciphersuites option
This option has been very likely been to fix some incompatibilities
between some TLS libraries. But nobody really remember what it fixes
and its usage today is questionable. So remove the option instead
of supporting an option we cannot even test anymore.

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2020-03-11 19:51:18 +01:00
Lev Stipakov
0dbbbd3020
support for --windows-driver option
Parse --windows-driver and set corresponding
value of config properties.

Could be used by clients to replicate openvpn2
behavior - use wintun driver if config contains
"--windows-driver wintun".

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2020-02-05 19:41:55 +01:00
Lev Stipakov
97f0407923
mac: add bypass route from socket_protect call
This is used to enable connectivity to a different remote
when force-tunneling is used and current VPN connection is broken.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2020-01-15 23:12:28 +01:00
Lev Stipakov
acec6e80ee
mac: add bypass route from socket_protect call
This is used to enable connectivity to a different remote
when force-tunneling is used and current VPN connection is broken.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2019-11-20 11:22:40 +01:00
Lev Stipakov
87d40ed8da ovpncli.cpp: socket_protect implementation for agent-enabled builds
socket_protect() is called before connecting to remote and this
makes sure that we will be able to (re)connect when there is
existing VPN connection and tunnel is broken.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2019-10-10 15:23:17 +03:00
Lev Stipakov
0d7143c4bf transport: enable socket_protect call for all platforms
This enables socket_protect call for all transports / platforms
with default implemenation being no-op.

This is needed for better round-robin DNS
fix for Connect clients (OVPN3-427).

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2019-10-10 15:23:17 +03:00
Antonio Quartulli
3166957e2e
add error codes for better error management at profile parsing time
Prefix error messages with a predefined string of the form:

ERR_PROFILE_xxxxx:

This way a user can parse the prefix and get a better understanding of
the error, without relying on the sole message.

Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2019-10-09 17:58:05 +02:00