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

3271 Commits

Author SHA1 Message Date
James Yonan
5a9fd26be7
RunContext: added process_exception() helper method
Signed-off-by: James Yonan <james@openvpn.net>
2021-08-03 10:42:35 +02:00
James Yonan
5231fa35ad
PacketStream: change message size validation logic to support growable buffers for DNS-over-TCP
In PacketStream, don't validate upper bound on message size
if BufferAllocated::GROW is set, allowing it to range up to
64kb.

Signed-off-by: James Yonan <james@openvpn.net>
2021-08-03 10:42:35 +02:00
James Yonan
abd1c5b208
PacketStream: minor cleanup and added a unit test
Removed declared_size_defined in favor of just setting
declared_size to a special value (SIZE_UNDEF) when it's
undefined.

Signed-off-by: James Yonan <james@openvpn.net>
2021-08-03 10:42:35 +02:00
James Yonan
95852fd24a
unittests: added THROW_FMT(...) convenience macro to throw an exception with printf-style argument substitution
Example:

  if (expect_throw != actual_throw)
    THROW_FMT("validate_size: bad throw, expect=%s, actual=%s, FC=%s size=%s",
	      expect_throw,
	      actual_throw,
	      fc.info(),
	      size);

Signed-off-by: James Yonan <james@openvpn.net>
2021-08-03 10:42:31 +02:00
Mark Deric
3cd0652d1e Add the getJoinedString() function
Useful in unit tests for which the input vector should be properly
sorted by the code under test.  This function is very similar to
getSortedJoinedString(), but it avoids sorting.  Because of the
similarity, the getSortedJoinedString() function is refactored to use
the new getJoinedString() function.

Signed-off-by: Mark Deric <jmark@openvpn.net>
2021-08-02 08:42:00 -07:00
Arne Schwabe
98f5b59a07 Document WEBAUTH and implement it as auth pending method in demo client
Signed-off-by: Arne Schwabe <arne@openvpn.net>
2021-07-28 14:50:06 +02:00
James Yonan
440b3a599d IP::Addr: remove explicit copy constructor that Coverity warns could throw
By removing the explicit copy constructor, we fall back to
a default copy constructor which would do a bitwise copy
of the object, which should be okay for this object, and
would have no potential to throw an exception.

Signed-off-by: James Yonan <james@openvpn.net>
2021-07-06 11:47:07 -06:00
Heiko Hund
0f11551143 remove CryptoOvpnHMACContext legal_dc_digest call
The class CryptoOvpnHMACContext is used for handling the --tls-auth
option. Since tls-auth is a control channel feature, checking for
a valid data channel digest is wrong.

Signed-off-by: Heiko Hund <heiko@openvpn.net>
2021-07-03 13:16:48 -06:00
James Yonan
b36f963db5 Added compiler profiles for linux-clang
The main difference between these and linux-cpp is that
linux-clang defines a different default DEP_DIR
($HOME/linux-clang) so that gcc and clang profiles can be
run on the same machine.

Signed-off-by: James Yonan <james@openvpn.net>
2021-07-03 13:10:01 -06:00
James Yonan
88ca59e0f6 unittests: helper now defines REGEX_WORKS to 1 if <regex> implementation is usable, and 0 otherwise
Signed-off-by: James Yonan <james@openvpn.net>
2021-07-03 13:10:01 -06:00
James Yonan
39719d64eb ProtoContext: added keepalive_timeout_early parameter
keepalive_timeout_early defines the keepalive_timeout
parameter early in the connection before the KeyContext
reaches ACTIVE.

It is set via the optional third parameter to the
"keepalive" directive, for example:

  keepalive 1 8 4

sets keepalive_timeout_early to 4 seconds.  If unspecified,
keepalive_timeout_early defaults to keepalive_timeout.

keepalive_timeout_early is useful on the server side to
reduce the resource footprint of abandoned connections,
and can be tuned to mitigate DDoS and UDP amplification
attacks.

Signed-off-by: James Yonan <james@openvpn.net>
2021-07-03 13:10:01 -06:00
Heiko Hund
f58ad6b739 remove CryptoAlgs::F_NO_CIPHER_DIGEST flag
Checking for AEAD cipher mode is sufficient.

Signed-off-by: Heiko Hund <heiko@openvpn.net>
2021-06-23 17:50:18 +02:00
Heiko Hund
17f7a7db1d send only supported IV_CIPHERS in peer info
Instead of sending static AES-GCM plus a few others, iterate
over supported data channel ciphers and send all of them.

Signed-off-by: Heiko Hund <heiko@openvpn.net>
2021-06-23 17:50:18 +02:00
Heiko Hund
efd7e01289 add dc_cipher/digest functions to CryptoAlgs::Alg
Moving interpretation of the flags into the class in preparation
of submitting only supported data channel ciphers in IV_CIPHERS.

Signed-off-by: Heiko Hund <heiko@openvpn.net>
2021-06-23 17:49:59 +02:00
Heiko Hund
2975585761 add CryptoAlgs::for_each() to interate algs
Signed-off-by: Heiko Hund <heiko@openvpn.net>
2021-06-18 15:10:03 +02:00
Heiko Hund
dd104e8392 make it possible to specify dc algorithms
DCO only supports a limited set of ciphers, currently it is
discovered quite late if a unsupported algorithm is configured
(or pushed).

This introduces CryptoAlgs::allow_dc_algs() with which the
supported set of data channel algorithms can be specified.

The DCO code makes use of this, at the time a new_controller()
is created.

Signed-off-by: Heiko Hund <heiko@openvpn.net>
2021-06-18 15:09:35 +02:00
Heiko Hund
84c8b4aca6 convert CryptoAlgs::algs array to std::array
Remove constexpr in preparation for making it possible to modify the
data channel ciphers. Use std::array so the SIZE can be specified.

Remove the unused CryptoAlgs:get_index_ptr() function.

Signed-off-by: Heiko Hund <heiko@openvpn.net>
2021-06-17 20:32:21 +02:00
Heiko Hund
d28b241380 combine the two CryptoAlgs::name functions
Signed-off-by: Heiko Hund <heiko@openvpn.net>
2021-06-17 20:16:51 +02:00
David Sommerseth
6530f876c8 OpenVPN 3 Core library version 3.6.3
Jira: VULREP-15
 URL: https://openvpn.atlassian.net/browse/VULREP-15
 -----BEGIN PGP SIGNATURE-----
 
 iQJHBAABCAAxFiEEgDq5E1p1aZrNLFFkhs+UTJZx/fIFAmDHst8THGRhdmlkc0Bv
 cGVudnBuLm5ldAAKCRCGz5RMlnH98pEaD/9VaUW4M9q7hpwzoCDqktrdaUzpRgvx
 hCYLSzAuIkAgPO1UXQTL6DWazTAI+vUAfuV+a4dgPmSs52qQ3K1UNUtuuQLurBiQ
 AopeNYY2VVZeVhAzDQDQTPsqCLn0Bigy4m4quJZBVOir+hGoSNnK7XTllNDCc8Li
 6PBIzM408B+6ARISxmxIdqlpsYwthYhRSPRPGTFuYqrbaRC85seHeRUTHTTQ/LVi
 uoAikYHm/IuY/CCNQoYX26M9FAtLA6zKWpPtJ4RzB+Muw8kToT5tpsKVZvjgwvN7
 YvcipYeALqQTf/WX7q8BKF24XzOYaZ1DHEuS8H3KLx66ESXHWZlfsb0uoj0Nv0AV
 HDloyhK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DTqC6wk2FHm1/ViVlSP5qPZkludSKrK58xz9G6TA9Vhnp0SfWWhXIw
 KmG7sbe9moC3W7o8gQf1SnlK5r+grpNvh+IGAl4sMggvCiZIsxwCK1Ptet8ag5AQ
 rI99XAaeje6snQ==
 =KuRd
 -----END PGP SIGNATURE-----

Merge tag 'release/3.6.3'

OpenVPN 3 Core library version 3.6.3

Signed-off-by: David Sommerseth <davids@openvpn.net>
2021-06-14 21:58:27 +02:00
David Sommerseth
d06e216e8c
Finalizing OpenVPN 3 Core library release v3.6.3
This is release fixes an issue with the building of the OpenSSL
dependency on Windows, where the OpenSSL library could load an
OpenSSL configuration file, resulting in loading external third-party
libraries.

Signed-off-by: David Sommerseth <davids@openvpn.net>
2021-06-14 20:07:08 +02:00
Lev Stipakov
f746588d45
vcpkg: add openssl port with no-autoload-conf
In default configuration OpenSSL loads config from
certain location on disk, which may pose a security risk.

There is "no-autoload-config" config option for OpenSSL
which disables this functionality:

   https://github.com/openssl/openssl/pull/5959

however it is not "exported" to vcpkg.

This adds openssl port overlay which sets "no-autoload-config"
config option. Here is the diff:

diff --git a/ports/openssl/windows/portfile.cmake
b/ports/openssl/windows/portfile.cmake
index 7a3bf08ed..c873eb756 100644
--- a/ports/openssl/windows/portfile.cmake
+++ b/ports/openssl/windows/portfile.cmake
@@ -21,6 +21,7 @@ set(CONFIGURE_OPTIONS
     enable-capieng
     no-ssl2
     no-tests
+    no-autoload-config
     -utf-8
     ${OPENSSL_SHARED}
)

There is also corresponsing PR to vcpkg:

  https://github.com/microsoft/vcpkg/pull/18389

When above PR is merged, this port overlay can be removed.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2021-06-11 13:01:09 +03:00
Lev Stipakov
7d33caef16
agent mac: Update license header
Signed-off-by: Lev Stipakov <lev@openvpn.net>
2021-06-10 23:27:27 +02:00
Lev Stipakov
d31620d0c6
agent mac: move from common
Windows agent has been moved from common to core,
so for consistency move mac agent too.

Since agent and agent-enabled client depend on jsoncpp,
also move jsoncpp build scripts.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2021-06-10 23:06:24 +02:00
Lev Stipakov
0ad1bfecc0
mac agent: customize agent name
We want PT agent and Connect agent co-exist,
so make agent name customizable at build time.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2021-06-10 23:06:23 +02:00
Lev Stipakov
f9bf96101d
mac agent: implement /add-bypass-route method
This method is called to enable connectivity to a different remote
when force-tunneling is used and current VPN connection is broken.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2021-06-10 23:06:22 +02:00
Lev Stipakov
c6d1f9465f
agent mac: fail-safe tun close
This adds a watchdog thread, which wakes up when client
process exits and closes tun. Watchdog is removed
when agent process exits.

To monitor process exit, we use kqueue's NOTE_EXIT event,
to interrupt waiting on graceful exit we use self-pipe trick.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2021-06-10 23:06:21 +02:00
Lev Stipakov
76d6a966cd
Fix core build with agent support for macOS
Signed-off-by: Lev Stipakov <lev@openvpn.net>
2021-06-10 23:06:20 +02:00
James Yonan
adb0cfe792
copyright: updated to 2017
Signed-off-by: James Yonan <james@openvpn.net>
2021-06-10 23:06:19 +02:00
James Yonan
45ec790c25
license : this branch (common) is proprietary, so remove all GPL headers.
Signed-off-by: James Yonan <james@openvpn.net>
2021-06-10 23:06:19 +02:00
James Yonan
d141ed63bf
httpcliset : minor refactor of new_request_synchronous() which removes SyncPersistState as a parameter (replacing with sps boolean) and moves it to private area of TransactionSet. 2021-06-10 23:06:18 +02:00
James Yonan
969bb36241
copyright : updated to 2016 2021-06-10 23:06:17 +02:00
James Yonan
99026b1df8
Mac agent : fixed a regression caused by this commit:
httpcliset : when preserve_http_state is false, close out
  the HTTPStateContainer before calling completion callback,
  so as to improve reentrancy-safety if completion callback
  tries to queue a new request.

The problem with the above commit is that it breaks
the interprocess socket-passing technique in
UnixCommandAgent::establish(), requiring that we deploy a
WS::ClientSet::SyncPersistState object to extend the
lifetime of the HTTP connection state.
2021-06-10 23:06:16 +02:00
James Yonan
aef8cf368c
For jsoncpp usage, rename deprecated misspelled method name:
getFormatedErrorMessages -> getFormattedErrorMessages
2021-06-10 23:06:15 +02:00
James Yonan
128adb83ec
Added Mac OpenVPN Agent client and service for processing tun setup using split-privilege model.
Added build script in mac/buildcli to build both client and
agent.
2021-06-10 23:06:14 +02:00
Arne Schwabe
af93c1879b
Fix multiple instances of comparison of signed with unsigned 2021-06-10 23:06:13 +02:00
James Yonan
5f9c70c704
Use openvpn::strerror_str() instead of std::strerror().
std::strerror() doesn't claim to be thread-safe, so
add openvpn::strerror_str() which is thread-safe by
virtue of the fact that it backs to strerror_r().

Signed-off-by: James Yonan <james@openvpn.net>
2021-06-10 23:06:12 +02:00
James Yonan
eaa24e939e
copyright: updated to 2017
Signed-off-by: James Yonan <james@openvpn.net>
2021-06-10 23:06:11 +02:00
James Yonan
afb7c39dca
license : this branch (common) is proprietary, so remove all GPL headers.
Signed-off-by: James Yonan <james@openvpn.net>
2021-06-10 23:06:11 +02:00
James Yonan
6e157dd76e
copyright : updated to 2016 2021-06-10 23:06:10 +02:00
James Yonan
ba54b90b39
Added class XmitFD for transmitting/receiving file descriptors over a unix domain socket (because Asio doesn't directly support this).
Also added a client/server test in test/xmitfd.
2021-06-10 23:06:09 +02:00
Lev Stipakov
8cae2a770b
asio: support for version 1.18
ASIO 1.18 enabled UNIX domain sockets on Windows,
which breaks our code, since we use Linux-specific
API to work with sockets.

Fix by disabling UNIX domain (local in ASIO terminology)
sockets on Windows.

Bump ASIO version to 1.18.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2021-06-10 22:43:26 +02:00
Heiko Hund
dee1b625c3
fix occ proto strings
There are two things addressed here.

 1) regression introduced by commit f1bdbe5088:
    Since TCP is not an alias for TCPv4 anymore the occ string
    contained TCP_CLIENT as proto, which is not understood by peers.
    Since only the "v4" version of the proto strings are understood
    the code was simplified.
 2) wrong occ proto string for TCP servers:
    Servers were also sending out the proto with client suffix. Fixed
    by passing in a boolean and returning the server version if true.

Also renamed the method to reflect better what it is used for.

Signed-off-by: Heiko Hund <heiko@openvpn.net>
2021-06-10 22:40:18 +02:00
Antonio Quartulli
cbbe9d1768
ovpndcocli.hpp: implement SessionStats::DCOTransportSource
The DCO component now implements the SessionStats::DCOTransportSource interface.
This interface is already used by ovpncli.cpp to retrieve the peer stats
from DCO.

With this patch, also the OvpnDcoCli object can be used to retrieve the
peer stats from kernel space.

Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2021-06-09 17:23:03 +02:00
Antonio Quartulli
73664bb85a
ovpndcocli.hpp: properly parse and store peer statistics
After invoking the get_peer() API, let the DCOClient component
extract the statistics and store them locally.

Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2021-06-09 17:23:03 +02:00
Antonio Quartulli
07b85394c8
genl.hpp: implement get_peer() API to retrieve peer data from DCO
The get_peer API allows userspace to retrieve the data about a specific
peer. Implement the userspace counterpart so that OpenVPN can retrieve
the peer data when it needs to updte the client statistics.

Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2021-06-09 17:23:03 +02:00
Antonio Quartulli
3bd5b40d6d
TunBuilder: add tun_builder_dco_get_peer() method
Allow external implementations to be informed when to
retrieve the peer data via DCO.

Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2021-06-08 01:42:37 +02:00
Antonio Quartulli
4fa0d6763e
ovpncli.cpp: update stats with DCO data before querying them
Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2021-06-08 01:42:37 +02:00
Antonio Quartulli
0f264b71e4
genl.hpp: avoid cast for return value of lambda expression
Explicitly specify the return type of lambda expressions
so that we can avoid casting the return value.

Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2021-06-08 01:42:37 +02:00
David Sommerseth
b4663454b2
openssl: Fix include file issues with OpenSSL compat.hpp
The compat.hpp header had issues when building on Debian 9, where it
complained about SSL_CTX_set1_curves() not being defined.  This was
due to openssl/ssl.h not being included inside the #if block where the
compat wrapper was defined.

Signed-off-by: David Sommerseth <davids@openvpn.net>
2021-06-03 19:09:17 +02:00
James Yonan
0670c1606b proto test: retry up to 5 times to prevent errors from blowing up the test
By default, the proto test uses a relatively small
handshake_window to intentionally trigger
KEV_NEGOTIATE_ERROR, so that we can test mid-session error
recovery.  However if KEV_NEGOTIATE_ERROR is hit on the
first primary key (i.e. first KeyContext with key_id == 0),
it is fatal to the session and will trigger a disconnect.

This change introduces a retry to prevent this
low-probability, false-positive corner case from
blowing up the test.

Signed-off-by: James Yonan <james@openvpn.net>
2021-05-31 23:21:30 -06:00