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

2180 Commits

Author SHA1 Message Date
Arne Schwabe
67fbe1ab3f OpenSSL 1.1: Use X509_check_purpose to check certificate types
The OpenSSL 1.1 check is a bit stricter than our own custom check but
OpenVPN 2.x uses the same (stricter) check.

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2019-04-15 15:47:22 +02:00
Arne Schwabe
7b5a92d58e OpenSSL 1.1: Change OpenSSL TLS version logic to match mbed TLS
The old logic was not matching and was also dubious (probably due the
confusion of OpenSSL TLS1_method meaning TLS 1.0 only)

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2019-04-15 15:47:22 +02:00
Arne Schwabe
c28b7d1893 OpenSSL 1.1: Adjust default OpenSSL cipher suites
This includes a bit saner default and also disallows cipher suites that
are not allowed in OpenVPN 2.x.

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2019-04-15 15:47:22 +02:00
Arne Schwabe
f108044a09 OpenSSL 1.1: Add defines for TLS 1.3 in tlsver.hpp
Signed-off-by: Arne Schwabe <arne@openvpn.net>
2019-04-15 15:47:22 +02:00
Arne Schwabe
ee1308b505 OpenSSL 1.1: Replace initialisation of RSA_meth with access method
Signed-off-by: Arne Schwabe <arne@openvpn.net>
2019-04-15 15:47:22 +02:00
Arne Schwabe
905d681af1 OpenSSL 1.1: Use standard tls methods
We modified the TLS method in OpenSSL. As accessing struct members is
no longer possible and OpenSSL does provide not access functions for
internal members, this hack cannot be supported anymore.

Clarify the comment of ssl_pending why it is needed

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2019-04-15 15:47:22 +02:00
Arne Schwabe
cf28e4600c OpenSSL 1.1: Change BIO wrappers around to use access methods
Accessing structs directly is forbidding in OpenSSL 1.1

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2019-04-15 15:47:22 +02:00
Arne Schwabe
5e6571163d OpenSSL 1.1: Implement compat methods for new BIO methods in 1.0.2
Signed-off-by: Arne Schwabe <arne@openvpn.net>
2019-04-15 15:47:22 +02:00
Arne Schwabe
8837539a73 Use std::nothrow as argument for new
This code surrunding the new allocation expects to have new return
nullptr in case it fails. By default however new throws an expection.

Use std::nothrow to make new behave as the code expects.

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2019-04-15 12:23:08 +02:00
Antonio Quartulli
e6ec025932
Merge branch 'qa' 2019-04-10 22:09:08 +02:00
Lev Stipakov
752a38c067 [OVPN3-397] size.hpp: wrap typedef in guards
NodeJS C++ environment defines ssize_t and causes
core build to fail because of type redefinition.

To fix, surround core's definition with same #ifdef guards
used in Node.JS.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2019-04-03 17:36:35 +03:00
Antonio Quartulli
d4e50f8c54
Merge branch 'qa' 2019-04-01 09:55:38 +02:00
Antonio Quartulli
d8d14e1991
[UCONNECT-1027] implement ResolveThread and ensure it is properly detachable
The new thread we create to perform the async DNS resolution must be
fully detachable. This is a strong requirement, because its parent (the
AsyncResolvable class) and the core itself may disappear by the time the
DNS resolution thread is ready to post the callback.

This situation can easily happen when the DNS resolution is hanging on a
non-working network, while the user has already terminated the core by
explicitly clicking 'disconnect' on the the UI.

Fix this issue by creating a ResolveThread class which can receive
a 'detach' signal from the parent when the latter is about to disappear.

The ResolveThread will then be able to understand that it was left alone
and will not post any callback.

Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2019-03-23 10:04:03 +01:00
Arne Schwabe
525a9a88a6 Merge branch qa
* schwabe/UCONNECT-1186-fix-custom-memcpy:
  Replace custom memcpy implementation
  Workaround for compiler bug in memneq
  [UCONNECT-1027] use one AsioWork object for the whole pre-resolve opertation
  Revert "[UCONNECT-1027] remotelist: create standalone object for resolve thread"

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2019-03-19 14:48:04 +01:00
Arne Schwabe
30ea53cb92 Replace custom memcpy implementation
The custom memcpy implementation is not faster than the
standard memcpy in my tests (standard one is assembler optimised on
almost all platforms).

Also the custom memcpy version crashes with a segfault on a current
Android clang/arm32 compiler. I suspect this due to the fact that it
ignores memory alignment.

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2019-03-19 14:42:45 +01:00
Arne Schwabe
de7c672ee7 Workaround for compiler bug in memneq
Use OpenSSL's or alternative implementation to avoid crashing on
Android armeabiv7a release builds.
2019-03-18 14:09:45 +01:00
Arne Schwabe
84fcecd5e7 Fix missing override annotation in udp/tcp/httpcli
Clang warns about these on default warning level.
2019-03-15 15:08:20 +01:00
Antonio Quartulli
1a3a69a496
[UCONNECT-1027] use one AsioWork object for the whole pre-resolve opertation
Using AsioWork directly inside a ResolveThread resulted in the
impossibility of the core to kill it, thus re-creating the original
problem of requiring the core thread to wait for the resolve to be
finished.

The original "i/o queue can be empty problem" appears only in case we
are performing a pre-resolve operation, because this is when there is
nothing else scheduled for the i/o reactor. Resolution operation within
tcp/udp/http clients do not really have this problem because they happen
in an already active context.

For this reason AsioWork can be moved out of the resolve thread and can
be used only during pre-resolve.
At the same time we want to retain control of the AsioWork object
because we HAVE TO kill it when the core is trying to stop. This
operation will ensure that the i/o reactor can be immediately
terminated.

For this reason, we move the AsioWork object into in the AsyncResolvable
class that is always reachable and allows the core to kill the Asiowork
object when needed (this was impossible when AsioWork was part of
ResolveThread).

Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2019-03-15 11:05:49 +01:00
Antonio Quartulli
c4cbf93f9b
Revert "[UCONNECT-1027] remotelist: create standalone object for resolve thread"
This reverts commit e3a2425be4.
2019-03-14 22:52:46 +01:00
Arne Schwabe
6ef089164e Allow unit tests to be also compiled with mbed TLS and on Windows 2019-03-12 11:36:29 +01:00
Arne Schwabe
7c67bf7f50 Add unit tests for route emulation and establish common test suite
This puts the log demo unit test and real route emulation into the same
unit test compilation unit to save compilation time.
2019-03-12 11:36:29 +01:00
Arne Schwabe
64a7b2f124 Add build file for core unit tests
Currently we only have unit test build file for Visual Studio. Add one
that is compatible with Unix like systems.
2019-03-12 11:36:29 +01:00
Arne Schwabe
0a0d080a49 Implement allowing local LAN access
On Android local networks need to be excluded from the default (or any
other route) route if they should bypass the VPN. This adds a callback
to specifically bypass the local LAN networks.
2019-03-12 11:36:29 +01:00
Arne Schwabe
2105b4b7c0 Fix Android route exclusion emulation
The old route emulation would immediately stop if the 0.0.0.0/0 was
in the routes to install.

Replace the old approach by first calculation a fine grained enough
set of routes and then only install those routes from this set that
should go via the VPN.
2019-03-12 11:36:29 +01:00
Antonio Quartulli
daf575ff50
Merge remote-tracking branch 'origin/qa' 2019-03-11 18:51:33 +01:00
Antonio Quartulli
e3a2425be4
[UCONNECT-1027] remotelist: create standalone object for resolve thread
The core might be asked to solve several hostnames and for this reason
it is racy to use one AsioWork object to coordinate them all.
The reason why it is racy is that a thread may likely be unsetting the
AsioWork object while we still have another ongoing resolution. This
will lead to the original problem of "the i/o queue is empty, core can
exit now".

To fix this, create a standalone ResolveThread class that is
instantiated once per resolve operation and that contains its private
AsioWork object.

Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2019-03-11 17:54:56 +01:00
Antonio Quartulli
e487b75860
async-resolve: use native GCD implementation on iOS
Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2019-02-24 10:03:41 +10:00
Antonio Quartulli
346ed043fa
Merge remote-tracking branch 'origin/qa' 2019-02-21 09:32:40 +10:00
Antonio Quartulli
3f55dcd266
remotelist: add missing includes
Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2019-02-21 09:31:08 +10:00
Arne Schwabe
073b3993f4 Fix commit 8b22a7b2 (mbed TLS compatibility)
The commit 8b22a7b2 had two mistakes:

Accidentally moving the #endif to the wrong line during reformat.
Forgetting to include mbedtls/version.h so the version check was always
false.
2019-02-12 14:04:40 +01:00
Arne Schwabe
8b22a7b209 Fix compatibility with mbed TLS < 2.7.0 2019-02-11 11:18:58 +01:00
Antonio Quartulli
934f4e741f
Merge remote-tracking branch 'origin/qa' 2019-02-07 20:09:36 +10:00
Antonio Quartulli
8c87c76969
[UCONNECT-1027] use proper io_context when initializing AsyncResolve class 2019-02-07 18:23:12 +10:00
Antonio Quartulli
c3026c65a6
Merge remote-tracking branch 'origin/qa' 2019-02-07 10:55:27 +10:00
Antonio Quartulli
f33fe76658
[UCONNECT-1027] perform async DNS resolution in a detached thread
When ASIO performs an async DNS resolution, it relies on the
getaddrinfo() syscall in order to obtain a result.

This syscall is non-interruptible by design, which means that, in case
of sudden stop command received by the user, the core will not be able
to terminate all its threads until the getaddrinfo() has returned
(either by timeout or with a result).

If the the external core user is synchronously waiting for it to
terminate (i.e. like a UI), this behaviour will lead to the entire
client hanging.

To avoid this issue, this commit converts each asynchronous DNS
resolution to a synchrnous one performed in a detached thread.

This way, if the core wants to stop, it can do so without waiting for
the DNS thread to join. Otherwise, this change should not lead to any
functional difference.

Signed-off-by: Yuriy Barnovych <yuriy@openvpn.net>
Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2019-02-07 09:07:00 +10:00
Lev Stipakov
0c0af6781e [OVPN3-342] Generate ICMP "packet too big" reply
When receiving packed from tun which size exceeds
mssfix value minus encap overhead, send ICMP
"destination unreachable" / "fragmentation needed"
(for IPv4) or "packet too big" (for IPv6) response.

This is required for non-TCP based protocols, since
for TCP we alter MSS in SYN segments.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2019-01-31 10:34:33 +02:00
James Yonan
c93af60a77 Move files from ovpn3-common to openvpn3 repo
Signed-off-by: James Yonan <james@openvpn.net>
Signed-off-by: Lev Stipakov <lev@openvpn.net>
2019-01-31 10:34:32 +02:00
Antonio Quartulli
d5eeb78ed9
ClientAPI: print core version when starting
Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2019-01-30 11:09:16 +10:00
Antonio Quartulli
04de9c4259
Merge branch 'qa' 2019-01-29 21:12:59 +10:00
Lev Stipakov
2c0dbc6c30 buildep.py: add asio patching
By some reasons, Windows dependencies build script
didn't apply patches for ASIO.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2019-01-23 11:09:54 +02:00
Arne Schwabe
600c680121 Allow updating auth-token during session
Signed-off-by: Arne Schwabe <arne@openvpn.net>
2019-01-15 14:17:37 +02:00
Antonio Quartulli
7391096b9e
[OC-85] tunprop: exclude routes for additional remotes also on macOS
Enable remote_bypass and pass full remote list to the macOS client,
so that it can connect to the next remote in case of reconnection.

Without remote_bypass enabled, the client will not be able to reach any
other server, when all the traffic is going through the VPN.

Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2019-01-09 18:39:54 +10:00
Antonio Quartulli
3587628d7c
[OC-84] tunprop: exclude routes for additional remotes also on Windows
Enable remote_bypass and pass full remote list to the Windows client,
so that it can connect to the next remote in case of reconnection.

Without remote_bypass enabled, the client will not be able to reach any
other server, when all the traffic is going through the VPN.

Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2019-01-09 18:39:38 +10:00
Antonio Quartulli
25471635de
Revert "[UCONNECT-868] When no network is present pause instead of stopping"
This reverts commit 72181f9e70.

Reverting as per Yuriy's request.
2019-01-03 20:34:57 +10:00
Lev Stipakov
6608878d57 [OVPN3-341] implement mssfix support
Adds mssfix support including optional
transport overhead. Some code has been ported
from openvpn2.

mssfix sets MSS option in TCP SYN to
a calculated value which guarantees that
size of UDP/TCP packet (which may or may not
include headers, see below) encapsulating
TCP segments won't exceed mssfix value.

If mssfix is used with optional "mtu" parameter,
then IP and UDP/TCP headers are also taken into account.

It is set in config like this:

    mssfix 1300 mtu

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2018-12-21 10:30:31 +02:00
Lev Stipakov
1bf3fc0e4a win: update project files
Remove Win32 target, set platform version to Windows 10 and set platform toolset to v141.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2018-12-21 10:30:31 +02:00
James Yonan
5713ff34af Fixed some breakage caused by recent endian/ffs commits
Signed-off-by: James Yonan <james@openvpn.net>
2018-12-19 12:08:43 +01:00
James Yonan
a9ce44a229 endian.hpp: break out endian compile-time tests to endian_platform.hpp
Signed-off-by: James Yonan <james@openvpn.net>
2018-12-19 11:55:38 +01:00
Antonio Quartulli
f8d2094353
travis: update to default osx image: xcode9.4 2018-12-19 09:20:55 +10:00
Antonio Quartulli
31eb246a8b
travis.yml: align deps version to lib-version
Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2018-12-19 08:01:27 +10:00