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

1813 Commits

Author SHA1 Message Date
Antonio Quartulli
fca9ed2feb [OVPN3-105] ParseClientConfig: avoid crash when not all key material is provided
Some profiles are expected to not contain each of the key/ca/cert
material and sometimes an encrypted key might be provided.

In these cases the ParseClientConfig object would trigger an exception
as the underlying SSLConfig object was not able to be fully
instantiated.

However this is expected with some profiles, therefore catch such
exceptions and continue the execution normally.

Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2017-12-22 17:59:38 +08:00
Antonio Quartulli
7299fefa77 [OC-42] Android: specify API level on command line
since the introduction of the unified headers, the API level
has to be specified on the command line, otherwise a development
API level (1000) will be used and will mess up older Android
releases.

On top of that, circumvent a bug in pthread.h by defining __LP32__.

This problem was causing crashes on Android 5 as it wasn't able to
provide libc functions expected by the precompiled ovpn3-core.

Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2017-12-22 17:59:38 +08:00
Antonio Quartulli
d3da3dfeb0 android: build client lib for x86 (for emulator)
Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2017-12-22 17:59:38 +08:00
Antonio Quartulli
8e501c5373 Update version for mbedTLS and lz4
Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2017-12-22 17:59:38 +08:00
Antonio Quartulli
e57676ead2 ParseClientConfig: export config to json format
With this method it is possible to convert the internal
config representation of a ParseClientConfig object
to json.

Any user needs to define HAVE_CONFIG_JSONCPP in order
to compile this method.

Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2017-12-22 17:59:38 +08:00
Antonio Quartulli
9aa715f07a ParseClientConfig: export configuration to ovpn file format
With this new method it is possible to convert a
ParseClientConfig object to an equivalent ovpn config
file.

The output is compliant with the config parser and could be
used to configure an OpenVPN client process.

Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2017-12-22 17:59:38 +08:00
Antonio Quartulli
1eab4cbfb7 ParseClientConfig: add helper constructor
This constructor takes only the profile content as argument.
It is quite useful when a user wants to create
a ParseClientConfig object starting from a plain .ovpn file,
without providing any other pre-parsed information.

Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2017-12-22 17:59:38 +08:00
Antonio Quartulli
71a59e41a2 ParseClientConfig: store the entire ovpn profile
Extend the ParseClientConfig class so that it can store
an entire OpenVPN profile. This way this class can basically
be mapped one-to-one with a user provided config file.

Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2017-12-22 17:59:38 +08:00
Antonio Quartulli
e0bb85a17f Transport: convert from transport protocol to config string
Add function to convert current transport protocol type
to the string that configured it.

Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2017-12-22 17:59:38 +08:00
Antonio Quartulli
2fe56c3be0 Compress: convert from ctx type to config string
Add function to convert the current compress context
type to the string that was used to configure it.

Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2017-12-22 17:59:38 +08:00
Antonio Quartulli
174ee25a13 OpenSSL: implement stub methods for new private_key_type/length() SSLAPIs
Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2017-12-22 17:59:38 +08:00
Antonio Quartulli
3d5770820b mbedTLS: implement private_key_type/length() API
Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2017-12-22 17:59:38 +08:00
Antonio Quartulli
a3210f0bb9 SSLAPI: add private_key_type/length() getter methods
These new API functions allow the user to retrieve the
type and the length of the private key.

An helper function to convert the type to a human readable
string is also provided.

Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2017-12-22 17:59:38 +08:00
Antonio Quartulli
8ffe8889cd OpenSSL: implement stub methods for new extract_* SSLAPIs
Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2017-12-22 17:59:38 +08:00
Antonio Quartulli
16e9160d89 mbedTLS: implement extended API for key material extraction
Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2017-12-22 17:59:38 +08:00
Antonio Quartulli
fe3d519145 SSLAPI: extend API with methods to extract key material
Users may want to print already parsed key material.
Extend the SSLAPI to accommodate methods for extracting
CA, CRL, CERT, KEY and DH data.

Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2017-12-22 17:59:38 +08:00
James Yonan
2b4c85091d Debugging: added header and build flag for valgrind run-time
extensions.

Signed-off-by: James Yonan <james@openvpn.net>
2017-12-22 17:59:38 +08:00
James Yonan
b948cde4c3 ManClientInstance::Factory: added virtual stop() method.
Signed-off-by: James Yonan <james@openvpn.net>
2017-12-22 17:59:38 +08:00
James Yonan
121e9752e7 client API: added portOverride
portOverride, like serverOverride, will override the port used
in the remote directive of the profile.

Signed-off-by: James Yonan <james@openvpn.net>
2017-12-22 17:59:38 +08:00
James Yonan
106981c3e2 JSON: allow alternative JSON library implementations
Allow source files that require JSON library functionality
to include a single file (openvpn/common/jsonlib.hpp) which
will then draw in the appropriate JSON library header based
on configuration #defines.

Code can #ifdef on HAVE_JSON to test whether or not JSON
functionality is available (previously, HAVE_JSONCPP
was used).

Currently supports JsonCpp and an OpenVPN-internal JSON
implementation.

This model assumes that alternative JSON implementations
are API-compatible with JsonCpp.

Signed-off-by: James Yonan <james@openvpn.net>
2017-12-22 17:59:38 +08:00
James Yonan
f206ae2647 logging: added logdatetime.hpp which prepends date/time to log lines
logdatetime.hpp is a drop-in replacement for logsimple.hpp, which
implements the OPENVPN_LOG() macro and variants using trivial
output to std::cout.  This version will prepend the date/time
to each log line.

Signed-off-by: James Yonan <james@openvpn.net>
2017-12-22 17:59:38 +08:00
James Yonan
49e933d275 Time: added to_double, delta_float, and delta_str methods
Signed-off-by: James Yonan <james@openvpn.net>
2017-12-22 17:59:38 +08:00
James Yonan
569b1da08e daemon.hpp: added class WritePid for managing pid files
Signed-off-by: James Yonan <james@openvpn.net>
2017-12-22 17:59:38 +08:00
James Yonan
63e9e046f8 ClientProto: reset CoarseTime object when AsioTimer is canceled
CoarseTime objects that track an AsioTimer must always be
reset when the AsioTimer is cancelled.  Not doing so can
cause a bug if the AsioTimer is reused after cancellation.

Signed-off-by: James Yonan <james@openvpn.net>
2017-12-22 17:59:38 +08:00
James Yonan
f64b501295 Cleanup: allow functor to be passed by value.
Previously Cleanup only allowed its functor argument to
be passed by rvalue reference.

Signed-off-by: James Yonan <james@openvpn.net>
2017-12-22 17:59:38 +08:00
James Yonan
ebe256068b RunContext: add configurable exit via EXIT_IN env var for debugging
Change the OPENVPN_EXIT_IN compile-time flag to be
a run-time option instead, controllable via the
EXIT_IN env var.  Set EXIT_IN to the number of
seconds to run before exiting.

Signed-off-by: James Yonan <james@openvpn.net>
2017-12-22 17:59:38 +08:00
James Yonan
1fbff4fed1 tls-crypt: revised server-side validate_initial_packet()
methods to use a BufferAllocated rather than a Buffer.

Signed-off-by: James Yonan <james@openvpn.net>
2017-12-22 17:59:38 +08:00
James Yonan
0090c51978 SSLConst: added new ssl_flags() method which filters out
non-ssl flags from given argument.

Signed-off-by: James Yonan <james@openvpn.net>
2017-12-22 17:59:38 +08:00
James Yonan
8379b0a319 CryptoDCInstance: added new RekeyType PRIMARY_SECONDARY_SWAP
and use it in ProtoContext::promote_secondary_to_primary()
since it more accurately reflects the underlying
implementation.

Note that this only affects DCO (data channel offload)
implementations.

Signed-off-by: James Yonan <james@openvpn.net>
2017-12-22 17:59:38 +08:00
James Yonan
18f45c244e ManClientInstance::Send: added AuthStatus::Type parameter
to disconnect_user() method.

Signed-off-by: James Yonan <james@openvpn.net>
2017-12-22 17:59:38 +08:00
James Yonan
4bba803f33 Listen::List: added expand_ports() method.
Signed-off-by: James Yonan <james@openvpn.net>
2017-12-22 17:59:38 +08:00
James Yonan
5122e7dc0f Listen::List: in port_offset(), set n_threads to 0 since
number-of-threads data for port_offset items isn't really
relevant.

Signed-off-by: James Yonan <james@openvpn.net>
2017-12-22 17:59:38 +08:00
James Yonan
4e11a6c89c StaticKey: added render_to_base64() and init_from_rng()
methods.

Signed-off-by: James Yonan <james@openvpn.net>
2017-12-22 17:59:38 +08:00
James Yonan
190ece92d4 CryptoAlgs: added mode() method.
Signed-off-by: James Yonan <james@openvpn.net>
2017-12-22 17:59:38 +08:00
James Yonan
76e65cf4c9 CryptoAlgs: added AEAD_NONCE_TAIL_SIZE constant (set to 8
bytes) to represent the size in bytes of AEAD "nonce tail"
normally taken from the HMAC key material.

Signed-off-by: James Yonan <james@openvpn.net>
2017-12-22 17:59:38 +08:00
James Yonan
27387181a8 compress: added method_to_string() method, i.e. the
inverse of parse_method().

Signed-off-by: James Yonan <james@openvpn.net>
2017-12-22 17:59:38 +08:00
James Yonan
7b47f998ad compress: since parse_method() performs a linear search
on method, reorder so that more frequently used methods
appear at the top of the list.

Signed-off-by: James Yonan <james@openvpn.net>
2017-12-22 17:59:38 +08:00
James Yonan
b428f742d1 library: added integer is_pow2() and log2() methods based on
efficient __builtin_ffs and __builtin_clz intrinsics.

Signed-off-by: James Yonan <james@openvpn.net>
2017-12-22 17:59:38 +08:00
Antonio Quartulli
4926011513 Android: adapt toolchain scripts to new SDK and move to API 26
Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2017-12-22 17:59:38 +08:00
Antonio Quartulli
ad4e995fae mbedTLS: use mbedtls API to initialize cert object
Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2017-12-22 17:59:38 +08:00
Lev Stipakov
908c611139 transport: use socket_protect to communicate socket handle on UWP
Signed-off-by: Lev Stipakov <lev@openvpn.net>
2017-12-22 17:59:38 +08:00
Lev Stipakov
92a62169d4 build win: read certain params from env
Required for Jenkins multibrach pipeline build.

OVPN3-99

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2017-12-22 17:59:38 +08:00
Lev Stipakov
8166ea8b3b common: define uwp platform macro
OVPN3-95

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2017-12-22 17:59:38 +08:00
Lev Stipakov
0186bf62c7 common: report platform name as "uwp"
OVPN3-94

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2017-12-22 17:59:38 +08:00
Lev Stipakov
3f291b0ddb netconf: disable getting hwaddr for UWP
OVPN3-93

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2017-12-22 17:59:38 +08:00
Lev Stipakov
6365d26b31 transport: external factory
Provide ExternalTransport::Factory interface to enable client instantiate transport factory.

OVPN3-92

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2017-12-22 17:59:38 +08:00
Lev Stipakov
2ffa0c9e36 transport: synchronous DNS lookup
Add config option to enable synchronous DNS lookup.

OVPN3-76

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2017-12-22 17:59:38 +08:00
Lev Stipakov
2c09c7c0b8 cliconnect.hpp: support for AsioWork always on
OVPN3-85

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2017-12-22 17:59:38 +08:00
Lev Stipakov
4f5a04db4e rand.hpp: allow external entropy source
OVPN3-84

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2017-12-22 17:59:38 +08:00
Lev Stipakov
b19c5da828 time.hpp: use GetTickCount64 on Vista and newer
OVPN3-87

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2017-12-22 17:59:38 +08:00