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

2075 Commits

Author SHA1 Message Date
Lev Stipakov
e9dc75ec90 sitnl: add unit tests
This adds unit tests for sitnl code.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2019-05-10 10:48:53 +03:00
Lev Stipakov
faad8454be sitnl: pick the best gw by longest prefix and lowest metric
Since we now handle multiple replies from Netlink,
we need to pick if the gateway with longest route prefix
and lowest metric.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2019-05-10 10:48:53 +03:00
Lev Stipakov
dfcc4bc437 [OVPN3-354] cli.cpp: support for round-robin DNS and redirect gw
This takes into use new TunSetup API which enables to create bypass
routes before establishing connection.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2019-05-10 10:48:53 +03:00
Lev Stipakov
8a502f3b61 [OVPN3-354] tun linux: support for round-robin DNS and redirect gw
When profile contains several remotes or single remote which
is resolved into multiple IP addresses AND all traffic is redirected
to the VPN, client will reconnect to the next remote if connection
is broken. Since all traffic is redirected to VPN, except traffic to
current remote, reconnect fails.

Currently this problem is solved by creating bypass routes
to all remotes before establishing connection, so that reconnect
won't go via broken VPN. This solution is sub-optimal, since
it leaks traffic to other remotes.

This patch implements a better approach. Before connecting to
remote, we create a bypass route just for this remote. On reconnect
we replace an old route with a new one for the new remote.
We piggyback on socket_protect() method of OpenVPNClient
which is called before opening connection to remote.

Connection to a new remote usually means a new IP address etc,
so to prevent traffic leakage we first create a new tun interface,
set up routes and then remove old routes and tear down old tun interface.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2019-05-09 16:40:24 +03:00
Lev Stipakov
c9315c7dc1 gwnetlink.hpp: specify destination when looking for gateway
When creating bypass route for server, it is better
to use gateway for server address instead of 0.0.0.0 or ::0.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2019-05-09 16:40:24 +03:00
Lev Stipakov
89f091daf0 sitnl: implement interface filtering when looking for gateway
This will be needed to exclude gateway on tun interface when
creating bypass route.

Note that this is required only for sitnl, since iproute-based routines
already ignore tun gateway.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2019-05-09 16:40:24 +03:00
Lev Stipakov
220de072a2 sitnl: support for multipart messages
Gateways are returned in multipart netlink
message, so we must properly handle those
instead of bailing out after reading first message.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2019-05-09 16:40:24 +03:00
Lev Stipakov
5771dfc0ee transport: remove ip_hole_punch API
That API was introduced in commit 5c00943
to implement persistence for macOS. That functionality
was refactored in 0609c76, but framework was left intact.

Since socket_protect() is called almost at the
same time as ip_hole_punch() and also receives
remote address, there is no need in this unused
API anymore.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2019-05-09 16:40:24 +03:00
Lev Stipakov
d448b4a7db tun/builder/client.hpp: use "override" method specifier
When overriding virtual methods, one must use "override"
specifier.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2019-05-09 16:40:24 +03:00
David Sommerseth
d85e92621d
Make reproducible builds possible
Packaging OpenVPN 3 Linux on Debian reports this warning:

openvpn3-core/client/ovpncli.cpp:1380:27: warning: macro "__DATE__" might prevent reproducible builds [-Wdate-time]
       ret += " built on " __DATE__ " " __TIME__;

Reproducible builds is something which will come arrive in more
distributions, as it is a good way to verify that binary builds contains
the expected source code and has not been mangled by the packager.

This changes the current behaviour and will not provide the date/time
stamps unless the OPENVPN_DEBUG macro has been set.  Enabling this
macro will re-enable the date/time stamp reporting via
OpenVPNClient::platform().

Signed-off-by: David Sommerseth <davids@openvpn.net>
2019-05-07 19:59:21 +02:00
Lev Stipakov
7150f72e09 tun: remove code duplications in Linux tun implementations
There are two ways how Linux tun can be manipulated -
by using iproute2 or netlink. Both implementations have
defined identical Setup class implementation.

This commit factors out Setup class from tun implementations
and templatizes it, which removes need in duplicated code.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2019-05-02 21:34:20 +03:00
Lev Stipakov
8112f0cd7c [OVPN3-378] cli: support for TunBuilder API
This enables to use TunBuidler API by test client
on Linux and Mac platforms.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2019-05-02 21:34:20 +03:00
Arne Schwabe
6f0e9f6388 Fix Asio 0003 patch.
When porting this patch I accidentally got the conflict backwards and
the resulting patch is nonsense. I am not sure how this managed to
survive a full Jenkins run.
2019-05-02 20:06:53 +02:00
Arne Schwabe
964662bacb Add /bigobj to build.py
The asio upgrade of 0.1.13 brought us over the limit of 65k
entitities in a single compilation unit. /bigobj allows more
methods

The ovpn3-core.vcxproj already uses this flag
2019-05-01 14:04:34 +02:00
Arne Schwabe
74e40a8907 Upgrade ASIO to 0.13.0
Also regenerate the patches against ASIO and fix merge conflicts
2019-05-01 14:04:34 +02:00
Antonio Quartulli
a2713ce1f6
PureTLS: enable SNI by default when configuring client
Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2019-04-30 09:03:31 +02:00
Antonio Quartulli
19a44dbdda
Merge branch 'qa' 2019-04-30 09:01:05 +02:00
James Yonan
a5fdf43726
InitProcess: comment clarification that crypto_init declaration causes SSL library init when instantiated
Signed-off-by: James Yonan <james@openvpn.net>
2019-04-30 08:59:34 +02:00
James Yonan
dec3bc140e
OpenSSL: Revert a commit that breaks OpenSSL initialization
commit e9c0bd00be
Author: Arne Schwabe <arne@openvpn.net>
Date:   Tue Oct 23 13:47:07 2018 +0200

    Remove unused private field

    crypto_init_ is not used at all and since it is a private field it is
    safe to remove.

We also revert the following commit which is redundant once the above
commit is reverted.

commit d87f5bbc04
Author: Antonio Quartulli <antonio@openvpn.net>
Date:   Thu Nov 15 21:03:46 2018 +1000

    OpenSSL: init library

    From the manpage:
    "SSL_library_init() must be called before any other action takes place."

    Signed-off-by: Antonio Quartulli <antonio@openvpn.net>

Signed-off-by: James Yonan <james@openvpn.net>
2019-04-30 08:59:30 +02:00
Lev Stipakov
16a4e3d4a7 [OVPN3-405] asio: A quick fix for incorrect error message encoding
ASIO's code for returning error messages doesn't play well with
non-ASCII chars. This quick fix makes ASIO use English.

A proper fix, which is more invasive (use FormatMessageW and
WideCharToMultiByte with UTF-8) will be provided separately.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2019-04-29 11:08:37 +03:00
David Sommerseth
aa785c30c1
Fix Base64::UCharWrap compiler warnings
Without this fix, some gcc compilers will issue the warning below when
building the reference client:

    ../../openvpn/common/base64.hpp: In constructor
    ‘openvpn::Base64::UCharWrap::UCharWrap(unsigned char*, size_t)’:
    ../../openvpn/common/base64.hpp:77:9: warning:
    ‘openvpn::Base64::UCharWrap::size’ will be initialized after [-Wreorder]
      size_t size;
             ^
    ../../openvpn/common/base64.hpp:76:17: warning:   ‘unsigned char*
    openvpn::Base64::UCharWrap::data’ [-Wreorder]
      unsigned char *data;
                     ^
    ../../openvpn/common/base64.hpp:63:2: warning:   when initialized here
    [-Wreorder]
      UCharWrap(unsigned char *data, size_t size):
      ^

This patch fixes this issue as well as removing a redundant public
declaration and fixing some whitespace issues.

Signed-off-by: David Sommerseth <davids@openvpn.net>
2019-04-25 22:02:54 +02:00
David Sommerseth
51a1469e6b
Merge various fixes
Signed-off-by: David Sommerseth <davids@openvpn.net>
2019-04-25 21:37:23 +02:00
David Sommerseth
218cfa39cb
Explicitly disable TAP support when parsing configurations
Since the Core Library doesn't really handle TAP mode, reject
configuration profiles expecting TAP mode as soon as possible.

Signed-off-by: David Sommerseth <davids@openvpn.net>
2019-04-23 15:59:39 +02:00
David Sommerseth
3a0e768ecd
Explicitly disable any potential TAP support
The TunWin::ClientConfig::layer_2_supported() returns true, while the
rest of the Core library does not handle TAP mode/OSI Layer 2 packets at
all.  This causes a challenge on Windows as it needs to have TAP support
on the virtual network device side - the tap-windows6 driver is TAP
only.  So this method must return true.  Currently OpenVPN just emulates
TAP mode by encapuslating TUN packets into somewhat proper Ethernet
frames.

Signed-off-by: David Sommerseth <davids@openvpn.net>
2019-04-23 15:59:39 +02:00
Arne Schwabe
aba98471fc Fix base64 unit test with mbedtls and windows
- the output buffer was sometimes too small in mbed tls
- msvc compiler does not like stack arrays with dynamic sizes
2019-04-18 14:47:16 +02:00
Arne Schwabe
9f84174f0b Add unit tests for Base64 2019-04-15 17:23:37 +02:00
Arne Schwabe
017bc545ce Add base64 decode for void* data
Also add some casts to avoid warnings
2019-04-15 17:23:37 +02:00
Arne Schwabe
452a353b2d Fix lzo build script to use it as dependency for the unit tests
Signed-off-by: Arne Schwabe <arne@openvpn.net>
2019-04-15 17:23:37 +02:00
Arne Schwabe
dfdd528dc1 Convert unit test to Googletest
Signed-off-by: Arne Schwabe <arne@openvpn.net>
2019-04-15 17:23:37 +02:00
Arne Schwabe
bd9ee482e6 Add copyright header to test_comp 2019-04-15 17:23:37 +02:00
Arne Schwabe
059f20f2b2 Move compression unit test from common to core repository
Signed-off-by: Arne Schwabe <arne@openvpn.net>
2019-04-15 17:05:09 +02:00
James Yonan
5a024cde5c Added Snappy corpus for testing compression/decompression.
Signed-off-by: Arne Schwabe <arne@openvpn.net>
2019-04-15 17:05:09 +02:00
Arne Schwabe
ec4d400933 Add compatibility functions for OpenSSL 1.1.0
OpenSSL1.1.0 is missing some connivence functions for getting n,e,p from
DSA/RSA. Add compatibility wrappers for the ones that we use.
2019-04-15 15:47:22 +02:00
Arne Schwabe
9768562a01 OpenSSL 1.1: Add argument to external sign to specify algorithm
In TLS 1.3 the RSA-PSS padding is required in addition to the
traditional PKCS1 padding used in TLS 1.2 and below. Add an
argument to the external sign function to signal what padding
is required. As quirkyness OpenSSL calls out requesting a NONE
padding instead of RSA-PASS.

We might need to move from RSA_method to EVP_PKEY_method in the
future.

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2019-04-15 15:47:22 +02:00
Arne Schwabe
1bbd2cc78c OpenSSL 1.1: Replace RSA_F_RSA_EAY_PRIVATE_ENCRYPT with Openssl variant
Signed-off-by: Arne Schwabe <arne@openvpn.net>
2019-04-15 15:47:22 +02:00
Arne Schwabe
c959a3cff0 OpenSSL 1.1: Replace remaining direct access to members
Signed-off-by: Arne Schwabe <arne@openvpn.net>
2019-04-15 15:47:22 +02:00
Arne Schwabe
4307f024ca OpenSSL 1.1: And missing remaining compat implementations
Signed-off-by: Arne Schwabe <arne@openvpn.net>
2019-04-15 15:47:22 +02:00
Arne Schwabe
3385c45151 OpenSSL 1.1: Use opaque pointer for HMAC_CTX
Signed-off-by: Arne Schwabe <arne@openvpn.net>
2019-04-15 15:47:22 +02:00
Arne Schwabe
f29453f4ca OpenSSL 1.1: Add compat includes for HMAC
Signed-off-by: Arne Schwabe <arne@openvpn.net>
2019-04-15 15:47:22 +02:00
Arne Schwabe
c107a1f6ab OpenSSL 1.1: Remove support for OpenSSL older than 1.0.0
Support for version 0.9.8 ceased on 31st December 2015.

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2019-04-15 15:47:22 +02:00
Arne Schwabe
024a10adc2 OpenSSL 1.1: Use EVP_MD_ctx as opaque pointer
Signed-off-by: Arne Schwabe <arne@openvpn.net>
2019-04-15 15:47:22 +02:00
Arne Schwabe
35d82906c4 OpenSSL 1.1: Change EVP_CIPHER ctx field to pointer
In OpenSSL 1.1 most types are opaque types that cannot directly accessed
or initialised. Accordingly change ctx to a pointer.

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2019-04-15 15:47:22 +02:00
Arne Schwabe
ebf4b7e87d OpenSSL 1.1: Use X509_digest to get certificate digest
Signed-off-by: Arne Schwabe <arne@openvpn.net>
2019-04-15 15:47:22 +02:00
Arne Schwabe
7d3e5d02f2 OpenSSL 1.1: Use SSL_get_ex_data instead of direct access
The OpenSSL manpage also points to use a function like (SSL_get_ex_data).
And we already use this functionality for storing and getting the SSL
class instance.

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2019-04-15 15:47:22 +02:00
Arne Schwabe
8717f822ca OpenSSL 1.1: Replace ctx->current with X509_STORE_CTX_get_current_cert
Signed-off-by: Arne Schwabe <arne@openvpn.net>
2019-04-15 15:47:22 +02:00
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