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

3446 Commits

Author SHA1 Message Date
Arne Schwabe
8fe1b0870d
Document -non-preffered-algorithms option in ovpncli
Signed-off-by: Arne Schwabe <arne@openvpn.net>
2022-01-12 18:30:05 +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
291e675748
Move SSL context from OpenSSL Context to OpenSSL Config
We already load the certificates from the config and need the SSL
library context initialised there to allow loading of keys encrypted
with legacy algorithm. Also ensure that enable legacy provider is
set before actually attempting to load the private keys.

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2022-01-12 18:29:50 +01:00
Frank Lichtenheld
307d5a4325 SafeStr: use std::numeric_limits instead of SIZE_MAX
It's the C++ way.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2022-01-12 17:56:35 +01:00
Frank Lichtenheld
88b0d28295 unittests: fix test_sitnl
- Test for CAP_NET_ADMIN instead of root.
  This correctly skips the test if you're root but have
  dropped capabilities, e.g. inside docker.
- Fix TestSetMTU to correctly ignore any additional lines
  in the output.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2022-01-11 15:00:44 +01:00
Arne Schwabe
fa30b27a78 Make delete_ a non-static member function of BufferAllocatedType
This changes the static delete_ call that get always called with
the same arguments to be just a normal member function.

GCC11 with address sanitizer otherwise complains that the destructor
might do a memset that writes to unallocated memory.
2022-01-11 12:54:03 +01:00
Frank Lichtenheld
b3e70d8a58 asio: add patch to fix unitialized warning with gcc 10+
Submitted to upstream: https://github.com/chriskohlhoff/asio/pull/968

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2021-12-27 10:23:30 +01:00
Frank Lichtenheld
e7d4834089 SafeStr: change constructor to handle size overflow
Throws error on newer gcc:
error: ‘void* memcpy(void*, const void*, size_t)’ writing 18446744073709551615 bytes into a region of size 9223372036854775807 [-Werror=stringop-overflow=]
  491 |       std::memcpy(write_alloc(size), data, size * sizeof(T));

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2021-12-22 10:32:13 +01:00
Frank Lichtenheld
d5f65e51e1 findcoredeps: remove noop line
That variable is not defined here, since we didn't call
any find_package for it.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2021-12-22 10:30:24 +01:00
Frank Lichtenheld
5f5f3be09a mac: Fix some issues in build-all
- No need to "build" asio twice.
- Avoid "[: =: unary operator expected" warnings due
  to undefined variables.
2021-12-22 10:29:42 +01:00
David Sommerseth
c4fa5a69c5
option: Extend with std::vector support in Option::from_list()
The Option class is lacking a way to take a std::vector of option values
and append those values to an option.

This is needed when importing an already pre-parsed configuration profile
into an OptionList object.

Signed-off-by: David Sommerseth <davids@openvpn.net>
2021-12-17 00:56:20 +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
f6d2c40b34 Remove unused outdated build scripts for the Android Java JNI client 2021-12-15 13:03:38 +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
Mark Deric
7fa1c70821
Add set -x to scripts conditioned on XTRACE=1
Signed-off-by: Mark Deric <jmark@openvpn.net>
2021-12-08 20:09:50 +01:00
Lev Stipakov
acdcab8675
ssl/proto: increment packet-id in control retransmit
Control packets are retransmitted if ACK hasn't been
received with certain time. This often happens with PUSH_REQUEST,
since it might take a while for the client to set up tun device and routing.
In this case client doesn't send ACK fast enough and server retransmits.

When using tls-auth (like in case of CloudVPN), most control packets
contain "packet-id" field. On retransmit, openvpn3 doesn't increment
packet-id value, unlike openvpn2. This triggers high verbosity replay
protection warnings in openvpn2 clients. Openvpn3 client also generates
replay errors, but they're only dumped to log at the end of session.

Fix by storing unencapsulated packets in send reliability object and
do encapculation on send and retransmit. This way packet-id will
be incremented on retransmit and no replay errors will occur on the
client side.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2021-12-08 17:02:36 +01:00
Arne Schwabe
7765540e58
Use idiosyncratic AES-GCM names for OpenSSL < 1.1.0
Signed-off-by: Arne Schwabe <arne@openvpn.net>
2021-12-07 20:37:18 +01:00
Arne Schwabe
a03e969536 Fix printing group name information on TLS connect
The compat function had a logic error (inverted condition) and
the size we gave to the function only 8 (size of a size_t) instead
of the size of the array. Use a std::array for the buffer to also have
a better size function than sizeof

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2021-12-06 16:18:46 +01:00
James Yonan
7cbac69e3d Linux tun_config(): added a flags parameter to subsume add_bypass_routes and create space for new flags
This change replaces the boolean add_bypass_routes with a new
flags parameter -- set the TunConfigFlags::ADD_BYPASS_ROUTES
flag to achieve the same functionality.

We also add some new flags for finer-grained control over
actions taken by tun_config:

* TunConfigFlags::DISABLE_IFACE_UP -- disable bringing the interface up

* TunConfigFlags::DISABLE_REROUTE_GW -- disable redirect-gateway

Signed-off-by: James Yonan <james@openvpn.net>
2021-11-24 13:18:35 -07:00
James Yonan
40490beabf TunProp::configure_builder: allow server_addr to be undefined
Signed-off-by: James Yonan <james@openvpn.net>
2021-11-24 13:18:35 -07:00
James Yonan
994ae2eed8 VPNServerNetblock: allow null configuration
Signed-off-by: James Yonan <james@openvpn.net>
2021-11-24 13:18:35 -07:00
James Yonan
ff7df50c39 SetUserGroup: extended to support Linux Capabilities
Added SetUserGroupRetainCap, which inherits from SetUserGroup,
and allows a privilege downgrade to retain one or more
Linux Capabilities.

Signed-off-by: James Yonan <james@openvpn.net>
2021-11-24 13:18:35 -07:00
James Yonan
46e7b3e2ff URL::Parse: improve support for bracketed hosts such as IPv6 addresses
Signed-off-by: James Yonan <james@openvpn.net>
2021-11-24 13:18:35 -07:00
James Yonan
cbb2018b3c WS::Client: fixed weird indentation
Signed-off-by: James Yonan <james@openvpn.net>
2021-11-24 13:18:35 -07:00
James Yonan
505d916dcc AuthCert: add common-name + serial-number constructor and use C++11 member initializers
Signed-off-by: James Yonan <james@openvpn.net>
2021-11-24 13:18:35 -07:00
James Yonan
a133c248fa ServerProto constructor: for performance, use move constructor for man_factory and tun_factory
Signed-off-by: James Yonan <james@openvpn.net>
2021-11-24 13:18:35 -07:00
James Yonan
7a829ede11 cli: fixed expected behavior of --write-url, -Z
cli -Z <file> is used by automated test scripts to write the
SSO URL to a file rather than launch a browser with the URL.

Recently this behavior changed on Linux where -Z now both
writes the URL to a file and also launches a browser with
the URL.  This patch reverts behavior back to only writing
the file.

Signed-off-by: James Yonan <james@openvpn.net>
2021-11-24 13:18:35 -07:00
James Yonan
41f6eaf11d TunIO: added an alternative TunIO constructor
TunIO only requires a Frame::Context, not an entire frame
object (which is an array of Frame::Context objects).

Signed-off-by: James Yonan <james@openvpn.net>
2021-11-24 13:18:35 -07:00
James Yonan
24b1990cf6 IPv4::Addr, IPv6::Addr: added static constexpr ip_version() method
Signed-off-by: James Yonan <james@openvpn.net>
2021-11-24 13:18:35 -07:00
James Yonan
e2aa56b472 OpenSSLCrypto::CipherContext::is_supported: fixed memory leak
The return value of cipher_type() is an allocated object,
therefore it needs to be held by a CIPHER_unique_ptr so
that it is properly freed.

Suggested-by: Arne Schwabe <arne@openvpn.net>
Signed-off-by: James Yonan <james@openvpn.net>
2021-11-24 13:18:03 -07:00
James Yonan
8914f7541f OpenSSLContext: fixed bug where lib_ctx was uninitialized in the class
lib_ctx is now member-initialized to nullptr.

Suggested-by: Arne Schwabe <arne@openvpn.net>
Signed-off-by: James Yonan <james@openvpn.net>
2021-11-24 13:16:49 -07:00
David Sommerseth
93767197a3
endian64: Fix non-Linux builds due to features.h
In commit 0baa4f19eb the features.h file was added to the include
list.  This breaks builds non-Linux platforms.  But it seems it is not
needed to have see the __GLIBC__ macro.

Signed-off-by: David Sommerseth <davids@openvpn.net>
2021-11-18 19:49:05 +01:00
David Sommerseth
a96d2fb140
openssl: Fix standalone builds using OpenVPN 3 OpenSSL API
The OpenVPN 3 Linux projects uses the OpenVPN 3 based OpenSSL API in one
of its unit tests.  This revealed a couple of missing #include files in
the the OpenSSL < 3.0 compat layer.

All testing was done on RHEL-8.5 with openssl-1.1.1k-4.el8.

Signed-off-by: David Sommerseth <davids@openvpn.net>
2021-11-18 18:40:31 +01:00
Frank Lichtenheld
b9e0d776fd
vcpkg-ports: add patch for jsoncpp
See https://github.com/open-source-parsers/jsoncpp/issues/1356

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2021-11-18 18:33:45 +01:00
Jeff Lucovsky
2996dfbe19
Build with ASAN when requested
This commit will build with ASAN when the environment variable ASAN=1.

Building with ASAN:
- Add "-fsanitize=address" to enable ASAN checks
- Add "-ggdb3" for higher-fidelity stack traces
- Add "-fno-omit-frame-pointer" to maintain fp info on call stacks

If both ASAN=1 and VAL=1, ASAN takes precedence.

Signed-off-by: Jeff Lucovsky <jeff.lucovsky@openvpn.net>
2021-11-18 18:33:44 +01:00
James Yonan
5580e89f5e
Fix inverted block/allow logic in TunProp::Config
The commit "tunbuilder: Fix inverted family block/allow logic"
(commit 5ba7fc1671) is incomplete without this additional
patch.

Signed-off-by: James Yonan <james@openvpn.net>
2021-11-18 18:30:55 +01:00
Frank Lichtenheld
e3a1f4a17a
dlgoogletest.cmake: Make sure we always set OVPN_GTEST_VERSION
Otherwise ExternalProject_add defaults to "master"
which is not only was a changing target but now it
doesn't even exist anymore since they renamed it to
"main".

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2021-11-18 18:28:54 +01:00
David Sommerseth
0baa4f19eb
endian64: Check of __GLIBC__ availability
When compiling this code using the musl libc instead of glibc, it fails
with this error:

./openvpn3-core/openvpn/common/endian64.hpp: In function 'uint64_t openvpn::Endian::rev64(uint64_t)':
./openvpn3-core/openvpn/common/endian64.hpp:53:14: error: '__bswap_constant_64' was not declared in this scope
   53 |       return __bswap_constant_64(value);
      |              ^~~~~~~~~~~~~~~~~~~

The __bswap_constant_64() is a function provided by the glibc library
and is not available in all other libc implementations.  To avoid this,
we fallback to the same solution used for Clang, which builds fine.  But
to avoid missing a match on the MINGW32 or MSC environments, the #if
condition checks are slightly reordered.

Signed-off-by: David Sommerseth <davids@openvpn.net>
2021-11-15 17:30:46 +01:00
David Sommerseth
8773add86a
endian64: Fix incorrect macro usage
The #if conditional need to check macros using defined(), otherwise the
behaviour is not ending up with the expected code.  In most compilers
these sections will never match.

Signed-off-by: David Sommerseth <davids@openvpn.net>
2021-11-15 17:30:39 +01:00
Arne Schwabe
5ace7b8ad4
Add missing override keywods in SSLContext
Signed-off-by: Arne Schwabe <arne@openvpn.net>
2021-11-12 20:59:43 +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
8a55626f3a
[OSSL3] Allow OpenVPN3 to always calculate OCC string for BF-CBC
We have a ton of legacy configurations that have no --cipher directive
and still use. Without this patch, the connection will fail when
calculating the OCC string. By hardcoding the values for BF-CBC we
can skip initialising the BF-CBC at this point. Almost all modern
OpenVPN server should push AES-256-GCM or another stronger cipher. If
the server does not push a cipher we will fail later with

Client exception in transport_recv: crypto_alg: BF-CBC: bad cipher for data channel use

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2021-11-12 20:58:45 +01:00
Arne Schwabe
7897c3bd7e
Rename OPENVPN_USE_TLS_MD5 to OPENVPN_ALLOW_INSECURE_CERTPROFILE
With OpenSSL 3.0 the name with MD5 no longer makes sense as it affects
not only MD5 but also SHA1 and number of other settings. So replace the
define with a more fitting name.

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2021-11-12 20:58:44 +01:00
Arne Schwabe
9ed6f69a3b
Remove old no longer used OpenSSL hack for Android 4.1 (Jellybean)
Signed-off-by: Arne Schwabe <arne@openvpn.net>
2021-11-12 20:58:43 +01:00
Arne Schwabe
af2bc1978e
[OSSL 1.1] Fix problem with old EC_method implementation
Casting EVP_KEY to EC_KEY is invalid.

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2021-11-12 20:58:42 +01:00
Arne Schwabe
843b30588b
[OSSL1.1/FIPS] Ignore unsusable cipehrs when running with FIPS mode
When running with the old FIPS mode in OpenSSL 1.0.2 and the Red Hat
patched OpenSSL 1.1.1 RHEL8 we need to check if the ciphers are actually
usable. Otherwise we get nasty errors when trying to use them later.

Note that OPenSSL 1.0.2 will still fail when the server picks
the OpenVPN PRF as we do not have a FIPS compatible PRF function for
OpenSSL 1.0.2.

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2021-11-12 20:58:41 +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