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

3107 Commits

Author SHA1 Message Date
David Sommerseth
5b15dbe940
Merge changes from Core library v3.5 2020-09-23 20:13:07 +02:00
David Sommerseth
e241c1b7a4
docs: Improve rendering of README
The GitHub rendering was not optimal and commit fa2919b27c added a few
more changes disabling HTML rendering completely.  This moves the
formatting closer to the .rst format GitHub supports.

Also fix a few various typ0s and a slight sentence improvement in the
new ovpn-dco section.

Signed-off-by: David Sommerseth <davids@openvpn.net>
2020-09-23 20:04:00 +02:00
James Yonan
1fe87f0842
Allow management layer to override keepalive parameters
Signed-off-by: James Yonan <james@openvpn.net>
2020-09-23 20:00:41 +02:00
James Yonan
3cfac11aa5
IP::Addr: added to_ipv4_zero() and to_ipv6_zero() methods
These methods return zeroed addresses when the
IP::Addr object itself is in an unspecified state.

Signed-off-by: James Yonan <james@openvpn.net>
2020-09-23 20:00:39 +02:00
James Yonan
ac79700fb2
Factored out timespec code from epoch.hpp into a new namespace TimeSpec
Signed-off-by: James Yonan <james@openvpn.net>
2020-09-23 20:00:34 +02:00
Arne Schwabe
2952f5611a Update OpenSSL to 1.1.1h
Signed-off-by: Arne Schwabe <arne@openvpn.net>
2020-09-23 09:28:42 +02:00
Lev Stipakov
b9e5936615
win/client/tunsetup.hpp: fix redirect-gw case for local remote
The case when server is in local network and pushes
redirect-gw wasn't properly handled - gw.defined() is false,
but gw.localroute() is true. We threw an exception
because we weren't able to get a gateway for bypass route.

Since in "server in local network" case bypass route
is not needed, fix it by skipping code branch which
checks for the gateway and installs bypass route.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2020-09-23 10:26:37 +03:00
Lev Stipakov
081b17fcbd
test_sitnl.cpp: add missing "override" specifier
Signed-off-by: Lev Stipakov <lev@openvpn.net>
2020-09-23 10:20:01 +03:00
Lev Stipakov
163c6399f8
tun/win/tunutil.hpp: fix mingw-discovered errors
Remove unused variable and make explicit cast.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2020-09-23 10:19:49 +03:00
Lev Stipakov
fa2919b27c README.rst: add instructions about ovpn-dco usage
Signed-off-by: Lev Stipakov <lev@openvpn.net>
2020-09-22 15:28:48 +00:00
Lev Stipakov
ae0d84be60 README.rst: Update Linux build steps
Switch to CMake buildsystem.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2020-09-22 15:28:48 +00:00
Lev Stipakov
6b3a5ba0ce
win/client/tunsetup.hpp: fix redirect-gw case for local remote
The case when server is in local network and pushes
redirect-gw wasn't properly handled - gw.defined() is false,
but gw.localroute() is true. We threw an exception
because we weren't able to get a gateway for bypass route.

Since in "server in local network" case bypass route
is not needed, fix it by skipping code branch which
checks for the gateway and installs bypass route.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2020-09-17 18:25:53 +03:00
Lev Stipakov
d8e99cf5c1 win: improve "add bypass route" logic
When adding bypass route to remote we always use
default gateway. This doesn't work when remote is not
reachable via default gateway (local network,
custom route - OVPN3-653).

Implement "get best gateway" logic by traversing routing
table and find gateway with longest prefix match and
highest metric.

In case of seamless tunnel and redirect-gw "get best gateway"
will return VPN gateway when adding bypass route during reconnect
to another remote. VPN tunnel is likely broken at this point
and bypass route via VPN make reconnect impossible.

Fix that by storing VPN interface index and, when finding best gateway,
filter routes which use VPN interface.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2020-09-16 18:08:15 +03:00
Lev Stipakov
7910b5dd7e win: improve "add bypass route" logic
When adding bypass route to remote we always use
default gateway. This doesn't work when remote is not
reachable via default gateway (local network,
custom route - OVPN3-653).

Implement "get best gateway" logic by traversing routing
table and find gateway with longest prefix match and
highest metric.

In case of seamless tunnel and redirect-gw "get best gateway"
will return VPN gateway when adding bypass route during reconnect
to another remote. VPN tunnel is likely broken at this point
and bypass route via VPN make reconnect impossible.

Fix that by storing VPN interface index and, when finding best gateway,
filter routes which use VPN interface.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
(cherry picked from commit e8030c2a421390a10506ec5dbfc6034f949aaf07)
2020-09-16 18:06:22 +03:00
Arne Schwabe
709bd10c24
Add warnings for 64bit block cipher and for SHA1 signed certificates
Example with ovpncli:

EVENT: WARN Proto: Using a 64-bit block cipher that is vulnerable to the SWEET32 attack. Please inform your admin to upgrade to a stronger algorithm. Support for 64-bit block cipher will be dropped in the future.

VENT: WARN TLS: received certificate signed with SHA1. Please inform your admin to upgrade to a stronger algorithm. Support for SHA1 signatures will be dropped in the future

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2020-09-16 15:41:16 +02:00
David Sommerseth
be600ff911
Merge Windows IP Helper API support
Signed-off-by: David Sommerseth <davids@openvpn.net>
2020-09-16 15:35:06 +02:00
Arne Schwabe
7eaa2893d4
Remove unused patch to fix compilation on Android
Signed-off-by: Arne Schwabe <arne@openvpn.net>
2020-09-09 18:58:54 +02:00
Arne Schwabe
1c751cc55b
Remove patch/code to allow unsupported name constraints in mbed TLS
This code was originally used in the Connect clients to allow PKIs that
use the (not commonly used) Name constraints feature. This is a
potential security risk but was done to allow PKIs that used that
feature. OpenSSL natively supports Name constraints and will check these.

Remove this hacky feature as feature as it also breaks compiling with
an unpatched mbed TLS and is not used by code anymore.
2020-09-09 18:58:53 +02:00
Lev Stipakov
242cdad9c9
win: add ipv4 routes via IP Helper API
Use ::CreateIpForwardEntry2() to add route instead of
expensive netsh call. Make it as a default choce.

Add unit test.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2020-09-09 18:25:38 +03:00
Lev Stipakov
4e837fe6ae
win/tunsetup.hpp: preparation for adding ipv4 routes via IP helper API
Factor out netsh route add call into own command class.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2020-09-09 18:25:25 +03:00
Lev Stipakov
9c6d5f5ef9
win/call.hpp: fix include and linkage error
Add missing include.

Remove "console_cp" global variable which prevented from including
call.hpp twice.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2020-09-09 18:24:58 +03:00
Lev Stipakov
d0e2e036eb
win: add ipv4 routes via IP Helper API
Use ::CreateIpForwardEntry2() to add route instead of
expensive netsh call. Make it as a default choce.

Add unit test.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2020-09-09 13:07:06 +03:00
Lev Stipakov
863fb68c3a
win/tunsetup.hpp: preparation for adding ipv4 routes via IP helper API
Factor out netsh route add call into own command class.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2020-09-09 12:54:11 +03:00
Lev Stipakov
9c6f67d271
win/call.hpp: fix include and linkage error
Add missing include.

Remove "console_cp" global variable which prevented from including
call.hpp twice.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2020-09-09 12:35:36 +03:00
Lev Stipakov
d79536240e
unittests/CMakeLists.txt: fix tests execution
Commit 941104cf4 refactored the way how test files are added, but
broke (disabled) execution of sitnl and cputime tests. Fix that.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2020-09-09 12:35:25 +03:00
James Yonan
777ff5556f
HTTP::HeaderList: minor performance fix
Return std::string() rather than the empty string.

Signed-off-by: James Yonan <james@openvpn.net>
2020-09-02 20:38:10 +02:00
James Yonan
5460d176c6
Added is_directory() method
Signed-off-by: James Yonan <james@openvpn.net>
2020-09-02 20:38:09 +02:00
James Yonan
a2bbb1d65c
kovpn.hpp: add dependent includes before #include <kovpn/kovpn.h>
Since userspace and kernel are different build environments,
it probably makes more sense to move includes in <kovpn/kovpn.h>
out to their enclosing scopes.

Signed-off-by: James Yonan <james@openvpn.net>
2020-09-02 20:38:08 +02:00
James Yonan
fc58a8b587
Configure_RPS_XPS, ProcFS: changes for Linux 5.4
Linux 5.4 is much more strict about validation of RPS CPU
bits, so we now need to count the number of CPUs and create
an exact mask rather than simply setting ffffffff.

Signed-off-by: James Yonan <james@openvpn.net>
2020-09-02 20:38:07 +02:00
James Yonan
ea9be93c7b
string: added repeat() method and redefined spaces() method to use it
Signed-off-by: James Yonan <james@openvpn.net>
2020-09-02 20:38:06 +02:00
James Yonan
d9a9ad35d7
string::trim_crlf: templatize to allow use with std::string or Buffer
Signed-off-by: James Yonan <james@openvpn.net>
2020-09-02 20:38:05 +02:00
James Yonan
9f8559f97b
read_binary_unix_fast: loop to fill buffer
Signed-off-by: James Yonan <james@openvpn.net>
2020-09-02 20:38:04 +02:00
James Yonan
75519e9e62
write_binary_unix: added more descriptive error messages
Signed-off-by: James Yonan <james@openvpn.net>
2020-09-02 20:38:02 +02:00
James Yonan
e27aa7e206
core.hpp: need to include <thread> for std:🧵:hardware_concurrency()
Signed-off-by: James Yonan <james@openvpn.net>
2020-09-02 20:38:01 +02:00
James Yonan
308b604c0a
Buffer: front() and back() members should be labeled as const
Signed-off-by: James Yonan <james@openvpn.net>
2020-09-02 20:38:00 +02:00
Arne Schwabe
012e7e8226
Refactor InitProcess to use refcounting
Although the init calls were protected by a mutex more than consumer of
the API will the second one if the uninit was called too early.

While at it, move from explicit init/uninit calls to RAII.

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2020-09-02 20:37:01 +02:00
David Sommerseth
ca61dd97db
Merge support for --redirect-gateway local from released 2020-09-02 20:35:47 +02:00
Arne Schwabe
595798a099 Move OpenSSL specific tlsver.hpp code to OpenSSL specific tlsverp.hpp
Replace the #ifdef OPENVPN_SSL_TLSVER_H that suggest the file is OpenSSL
specific with a pragma once
2020-08-27 16:53:36 +02:00
Arne Schwabe
a61bc006d3 Use correct API for setting minimum TLS version on OpenSSL 1.1+
The new API also allows us to revert a higher minimum API an operating
system might have

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2020-08-27 13:00:11 +02:00
Arne Schwabe
285474a6dc Implement TLS Keying Material Export data key derivation
Tested against OpenVPN 2.x server

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2020-08-27 13:00:11 +02:00
Arne Schwabe
6bae57ab4f Document the protocol used in OpenVPN for Web based authentication
Signed-off-by: Arne Schwabe <arne@openvpn.net>
2020-08-27 10:27:08 +02:00
Lev Stipakov
4fcb3624f7 ovpn-dco: linux client support
- add tunbuilder support to OvpnDcoClient

Linux client uses core library in non-privileged
process which cannot do modify routing, add/remove interfaces etc.

Those operartions are executed in separate privileged
process via tunbuilder API.

 - pass data between userspace/kernel via pipe

In Linux client, control channel packets are handled by
unprivileged process, which doesn't have direct access to netlink
socket to talk directly to kernel module. In order to enable
communication with kernel by unprivileged process, receiving side
of tunbuilder API, which itself is ran in privileged process,
creates socketpair and connects netlink socket with another socket,
which is passed back to unprivileged process. Unpriviled process
uses that socket to communicate with kernel module instead of GeNL
object.

 - remove remnants of kovpn support from tunbuilder and tunbuilder
support from kovpn tun/transport client.

Kovpn doesn't need tunbuilder support, so relevant code is removed.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2020-08-26 14:59:24 +00:00
Lev Stipakov
f24f1fd089 ovpn-dco: handle keepalive
Since userspace doesn't know anything about data
channel traffic, keepalive should be handled in kernel.

Disable keepalive in userspace and implement
OVPN_CMD_SET_PEER ovpn-dco command, which sets
keepalive settings in kernel.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2020-08-26 14:59:24 +00:00
Lev Stipakov
60e43763a4 ovpn-dco: init data channel keys
Implement OvpnDcoRekey, which parses key info
into format consumed by ovpn-dco.

Use KoRekey abstractions to hook into protocol layer
and get notified about rekeying events.

Pass new key to kernel or swap keys when commanded by
protocol layer.

Implement ovpn-dco netlink commands:

 - OVPN_CMD_NEW_KEY
 - OVPN_CMD_DEL_KEY
 - OVPN_CMD_SWAP_KEYS

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2020-08-26 14:59:24 +00:00
Lev Stipakov
9a15079d25 kocrypto.hpp: factor out kovpn-specific code
In preparation for ovpn-dco support, move kovpn-specific code
out of KoRekey::Key into own Korekey::KovpnKey class.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2020-08-26 14:59:24 +00:00
Lev Stipakov
275e422501 ovpn-dco: configure network properties
Upon connecting, set network device IP address,
configure routes etc.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2020-08-26 14:59:24 +00:00
Lev Stipakov
8593c41540 ovpn-dco: basic communication with kernel module
Add dependency to libnl-genl, which is C library
for generic netlink communication.

Implement C++ wrapper for libnl-genl, inspired by
ovpn-cli - a test client for ovpn-dco kernel module.

Implement ovpn-dco netlink commands:

  - OVPN_CMD_START_VPN - pass transport socket,
protocol (UDP) and mode (client).

  - OVPN_CMD_NEW_PEER - pass local and remote
endpoint info.

  - OVPN_CMD_PACKET - move (control channel) packets
between userspace and kernel.

  - OVPN_CMD_DEL_PEER - sent by kernel when peer is deleted
due to keepalive timeout (causes reconnect) or any other
reason (considered as fatal).

This change allows to perform openvpn handshake and
establish connection which doesn't work, since data channel
keys are not passed to kernel yet.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2020-08-26 14:59:24 +00:00
Lev Stipakov
67988b8883 linux/client/tunsetup.hpp: initial ovpn-dco support
ovpn-dco doesn't have concept of "opening" nor
file descriptor, since communication is handled
via netlink (to be added later).

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2020-08-26 10:53:27 +00:00
Lev Stipakov
3761f2ff89 ovpn-dco: initial support
Add tun/transport client skeleton for ovpn-dco,
which doesn't do any work except creating/removing
ovpn-dco device.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2020-08-26 10:53:27 +00:00
Lev Stipakov
e419e07c7f dcocli.cpp: add missing socket_protect call
As other transport clients, call socket_protect()
before establishing connection.

This gives ability to create bypass route.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2020-08-26 10:53:27 +00:00