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

2065 Commits

Author SHA1 Message Date
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
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