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

207 Commits

Author SHA1 Message Date
Antonio Quartulli
be38bbeb84
tls-crypt-v2: test/ssl/proto.cpp - extend protocol test
Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2018-12-06 09:19:22 +10:00
Arne Schwabe
2ea88a93ba Add Remote endpoint information to protect_socket call
On the linux client we need the information to which remote the client
is connecting to query the route information to ultimately discover the
device. On other platform that do not need these extra information we
ignore the extra arguments

The API uses std::string and bool instead of passing of passing IPAddr as
the API needs to be understand by Swig/Java and similar methods also opt in
favour of call by value and simply types.

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2018-12-04 13:33:18 +01:00
Antonio Quartulli
0a081ee17f
[OVPN3-315] cli/go: add option to compile SITNL component
Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2018-11-30 08:51:14 +10:00
David Sommerseth
4a25059f5c
test/ovpncli: Don't override PROF env variable
If the PROF env variable is already set, respect that original value
instead of enforcing a value which might be wrong on the build host.

Signed-off-by: David Sommerseth <davids@openvpn.net>
2018-11-07 17:57:08 +01:00
Antonio Quartulli
8d9834b793
cli: build with OPENVPN_VERSION generated from commit id
Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2018-06-25 16:37:51 +08:00
James Yonan
0e673f1e0b Cleaned up cli build script
Also added an option to build with OpenSSL
instead of mbedTLS.

Signed-off-by: James Yonan <james@openvpn.net>
2018-05-21 11:34:01 +03:00
Antonio Quartulli
d9b5055cda
[OVPN3-169] cli.cpp: compile with -DOPENVPN_TLS_LINK when requested
Compile with -DOPENVPN_TLS_LINK if TLS=1 was specified on
the command line

Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2018-04-19 17:38:19 +08:00
James Yonan
59de63fa65
cli.cpp: added OPENVPN_REMOTE_OVERRIDE
For testing, add the capability to get the next "remote"
directive from the output of an external script or binary.

Signed-off-by: James Yonan <james@openvpn.net>
2018-03-26 23:58:35 +08:00
Lev Stipakov
0edec4a097
[OVPN3-206] win: update directories in VS projects
Signed-off-by: Lev Stipakov <lev@openvpn.net>
2018-03-26 23:58:33 +08:00
James Yonan
01ee1f5a41
Added ClientAPI::Config::retryOnAuthFailed parameter
// If true, consider AUTH_FAILED to be a non-fatal error,
  // and retry the connection after a pause.
  bool retryOnAuthFailed = false;

Signed-off-by: James Yonan <james@openvpn.net>
2018-03-10 02:28:33 +08:00
James Yonan
eedee4fa6d
cli.cpp: allow -s server override to reference a friendly name
The OpenVPN 3 config file parser allows an embedded server list,
given as:

  setenv SERVER <HOST1>/<FRIENDLY_NAME1>
  setenv SERVER <HOST2>/<FRIENDLY_NAME2>
  . . .

This patch allows the -s server override to specify
a friendly name and will substitute the host or IP
address given in the server list.

Signed-off-by: James Yonan <james@openvpn.net>
2018-03-10 02:28:32 +08:00
David Sommerseth
16b10559f2 [OVPN3-140] Update company names in copyrights
OpenVPN Technologies, Inc. change their name to OpenVPN Inc. during the
autumn of 2017.

Signed-off-by: David Sommerseth <davids@openvpn.net>
2017-12-22 17:59:39 +08:00
David Sommerseth
6caca2c313 [OVPN3-140] Relicense back to AGPLv3
This is essentially a revert of commit 04b2a3c9b7 and commit
ef42e59e05.

Signed-off-by: David Sommerseth <davids@openvpn.net>
2017-12-22 17:59:39 +08:00
Antonio Quartulli
577b5ca7b4 cli.cpp: fix typ0 in define
Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2017-12-22 17:59:39 +08:00
Antonio Quartulli
3928069caa [OVPN3-119] mbedTLS: create INSECURE profile including MD5
Following an high number of users complaints, it was suggested
to re-enable MD5 and to give our users a notice period of some
months before dropping its support entirely.

With this patch we add a new certificate profile called "insecure"
which is equal to "legacy" with the addition of MD5.

By default OpenVPN3 still use legacy and the insecure profile
must be enabled explicitly by the client app.

The new profile is also enveloped in an ifdef so that
such support is not introduced, unless who builds the core
knows about it.

Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2017-12-22 17:59:39 +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
Antonio Quartulli
f33e7c2968 [OVPN3-5] tls-crypt: add tls-crypt support in proto.hpp test unit
By default tls-crypt is now enabled instead of tls-auth.
It can be easily changed by editing the define at the top
of test/ssl/proto.hpp

Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2017-09-27 16:16:18 +08:00
Antonio Quartulli
389353c243 proto.cpp: uninit process at the end of the execution
Not really important, but worth fixing to avoid polluting
any memchecker output with unreleased (leaked) resources.

Release process resources before exiting the main function.

Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2017-09-27 16:16:18 +08:00
Lev Stipakov
8ae2a3f7cf Integrate Google Test framework
Implemented sample test for LogInfo class.

OVPN3-27
2017-09-27 16:16:18 +08:00
Lev Stipakov
96e0d89454 Revert "Merged in OVPN3-21-prepend-log-record-with-unique- (pull request #7)"
This reverts commit 62423c91cb, reversing
changes made to f26b08b6ef.
2017-09-27 16:16:18 +08:00
Lev Stipakov
cce245587b Prepend log string with unique reference.
OVPN3-21

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2017-08-08 11:35:37 +03:00
James Yonan
f89da9619e OpenVPN 3 client: added single-thread mode:
* enabled by OPENVPN_OVPNCLI_SINGLE_THREAD compile flag.

* turns off the signal blocker.

* Adds overrideable clock_tick() virtual method with
  configurable frequency that is used when processing
  signals when the OpenVPN client is running in
  single-thread mode.

Signed-off-by: James Yonan <james@openvpn.net>
2017-04-12 12:37:41 -06:00
James Yonan
691a641a43 Added i/o abstraction layer.
Created a lightweight abstraction layer so that another i/o
reactor can be dropped in place of asio.

The basic approach is to rename all references to asio::xxx
types to openvpn_io::xxx and then make openvpn_io a
preprocessor variable that points to the top-level namespace
of the i/o reactor implementation.

All of the source files that currently include <asio.hpp> now
include <openvpn/io/io.hpp> instead:

This gives us a lightweight abstraction layer that allows us
to define openvpn_io to be something other than asio.

Other changes:

* Inclusion of asio by scripts/build is now optional, and is
  enabled by passing ASIO=1 or ASIO_DIR=<dir>.

* Refactored openvpn/common/socktypes.hpp to no longer
  require asio.

* Refactored openvpn/log/logthread.hpp to no longer require
  asio.

* Added openvpn::get_hostname() method as alternative to
  calling asio directly.

* openvpn/openssl/util/init.hpp will now #error
  if USE_ASIO is undefined.

Signed-off-by: James Yonan <james@openvpn.net>
2017-03-30 15:48:14 -06:00
James Yonan
b2cd82a5bf copyright: updated to 2017.
Signed-off-by: James Yonan <james@openvpn.net>
2017-03-18 13:11:09 -06:00
James Yonan
fc85b371ab logging: removed #ifdef OPENVPN_INSTRUMENTATION, and made
the previously conditional code always included.
2017-03-18 12:24:54 -06:00
James Yonan
88ae6eba36 SSL : added tls-cert-profile directive for mbedTLS.
legacy            -- allow 1024-bit RSA certs signed with SHA1
preferred         -- require at least 2048-bit RSA certs signed
                     with SHA256 or higher
suiteb            -- require NSA Suite-B

The current default is legacy.

The directive can be set in the profile or overridden/defaulted
in the client API via ClientAPI::Config::tlsCertProfileOverride
var.

TODO: implement for OpenSSL.
2017-03-18 12:24:54 -06:00
James Yonan
050e8717f1 mbedTLS: Port from polarssl-1.3 to mbedtls-2.3 (symbol renames)
This patch renames internal OpenVPN 3 symbols
from polarssl -> mbedtls.

Signed-off-by: James Yonan <james@openvpn.net>
2017-03-18 12:24:54 -06:00
James Yonan
a6b7cf458f mbedTLS: Port from polarssl-1.3 to mbedtls-2.3 (functional)
This patch builds on work by David Sommerseth <davids@openvpn.net>
to move the PolarSSL API from polarssl-1.3 to mbedtls-2.3, which
has significant differences in some areas.

- Strings containing keys, certificates, CRLs, and DH parameters
  need to be NULL-terminated and the length argument provided to
  the corresponding mbedtls parse function must be able to read
  the NULL-terminator.  These places have been modified with a
  '+1' to the length argument (x509cert.hpp, x509crl.hpp, dh.hpp,
  pkctx.hpp).

- The SSL context object has been split up in mbedtls-2.3
  Now many of the SSL configurations are done in a separate
  SSL config object, which is added to the SSL context once
  configured.  In addition private/public keys are now stored
  in a separate pk_context, which is later on attached to the
  SSL context.  Due to this, many of the calls setting either
  SSL configuration parameters or working with pk_contexts have
  been refactored.  (sslctx.hpp)

- The older API loading the CA chain took a hostname argument.
  The new API requires mbedtls_ssl_set_hostname() explicitly to
  be called setting hostname.  Some refactoring was needed here
  too (sslctx.hpp).

- x509_oid_get_description() is now replaced by
  mbedtls_oid_get_extended_key_usage().

- when mbedTLS renamed OID_CMP to MBEDTLS_OID_CMP, the return
  value was changed so that a return value of 0 now means equal
  rather than not-equal.

- mbedtls/platform.h must be loaded before any other mbedtls
  include files (sslchoose.hpp).

- All functions and macros related to mbedTLS are now prefixed
  with mbedtls_/MBEDTLS_

- Refactored External PKI and added some options to cli.cpp
  to make it easier to test that the feature still works
  correctly.  This included removing the sig_type var and
  standardizing on a PKCS#1 digest prefix per RFC 3447.

- Updated test keys to 2048 bits.

- Updated dependency build scripts to build mbedTLS.

- Enable MD4 in mbedTLS build script (needed for NTLM auth).

- Use an allow-all X509 cert profile to preserve compatibility
  with older configs.  Going forward, we will implement new
  options to increase strictness on minimum RSA key size and
  required cert signing algs.

- Added human-readable reason strings that explain why
  a given cert in the chain wasn't accepted.

- This patch doesn't rename any files or rename internal
  OpenVPN 3 symbols such as PolarSSLContext.  This will
  be done in a separate commit.

Signed-off-by: James Yonan <james@openvpn.net>
2017-03-18 12:24:54 -06:00
Samuli Seppänen
04b2a3c9b7 Switch from AGPLv3 to GPLv3
Signed-off-by: Samuli Seppänen <samuli@openvpn.net>
2017-03-16 14:43:55 +02:00
James Yonan
971abda88f copyright : updated to 2016 2016-09-03 23:29:23 -06:00
James Yonan
662bf7833e ovpn3 core : Added automatic data limits for Blowfish,
Triple DES, and other 64-bit block-size ciphers vulnerable
to "Sweet32" birthday attack (CVE-2016-6329).  Limit such
cipher keys to no more than 64 MB of data
encrypted/decrypted.  While our overall goal is to limit
data-limited keys to 64 MB, we trigger a renegotiation
at 48 MB to compensate for possible delays in renegotiation
and rollover to the new key.

This client-side implementation extends data limit
protection to the entire session, even when the server
doesn't implement data limits.

This capability is advertised to servers via the a
peer info setting:

  IV_BS64DL=1

meaning "Block-Size 64-bit Data Limit".  The "1" indicates
the implementation version.

The implementation currently has some limitations:

* Keys are renegotiated at a maximum rate of once per
  5 seconds to reduce the likelihood of loss of
  synchronization between peers.

* The maximum renegotiation rate may be further extended
  if the peer delays rollover from the old to new key
  after renegotiation.

Added N_KEY_LIMIT_RENEG stats counter to count the number
of data-limit-triggered renegotiations.

Added new stats counter KEY_STATE_ERROR which roughly
corresponds to the OpenVPN 2.x error "TLS Error:
local/remote TLS keys are out of sync".

Prevously, the TLS ack/retransmit timeout was hardcoded to
2 seconds.  Now we lower the default to 1 second and make
it variable using the (pushable) "tls-timeout" directive.
Additionally, the tls-timeout directive can be specified
in milliseconds instead of seconds by using the
"tls-timeout-ms" form of the directive.

Made the "become primary" time duration configurable via
the (pushable) "become-primary" directive which accepts
a number-of-seconds parameter.  become-primary indicates
the time delay between renegotiation and rollover to the
new key for encryption/transmission.  become-primary
defaults to the handshake-window which in turn defaults
to 60 seconds.

Incremented core version to 3.0.20.
2016-09-01 15:19:00 -06:00
James Yonan
83a2e3584f cli : updated ovpn3 command line client to no longer delay
one second before handling INFO,OPEN_URL messages since
the ovpn3 core now implements the delay internally.
2016-08-17 15:26:08 -06:00
James Yonan
ba15049f18 Mac client : implemented INFO,OPEN_URL handler for Mac OS X
command line client.
2016-08-11 14:05:33 -06:00
James Yonan
899fa6c4bc ovpn3 client API : added sslDebugLevel parameter to control
the logging level of the underlying SSL library.
2016-08-04 20:43:43 -06:00
James Yonan
ca5205b4f3 random : consolidate random functionality in RandomAPI. 2016-06-28 22:31:17 -06:00
James Yonan
94ffa2318c ovpn3 "cli" client : support DEBUG=3 in build script
to enable full debug info and disable optimization.
2016-06-26 21:56:53 -06:00
James Yonan
2f1fd1ad83 Added INFO notification to OpenVPN control channel protocol:
INFO,<payload>

Payload can be any UTF-8 printable string under 64 KB
(multiple lines are okay).

INFO notifications can be sent from server to client
in real-time, on any active client connection.

The client will attach the payload to an INFO event and
forward it to the controlling app via the event callback:

  virtual void event(const Event&) = 0;
2016-05-10 17:53:09 -06:00
James Yonan
74d89fab7c OpenVPN protocol core : when passing objects to methods that
may assert ownership over them, use C++11 rvalue/move
semantics.
2016-05-10 13:02:11 -06:00
James Yonan
2255bab03a OpenVPN protocol core : added logic to control channel
receive path to reassemble messages fragmented by the
SSL layer up to a max message size of 64 KB.

Ramifications:

* Peer info data and pushed options can be significantly
  larger (i.e. approaching 64 KB).

* Less need for the options continuation feature.

Limitations:

* While this patch doesn't change the underlying OpenVPN
  protocol, it can result in messages being sent that are
  fragmented by the receiving SSL implementation into
  multiple buffers.  Implementations that lack reassembly
  capabilities (such as OpenVPN 2.x at this point in time)
  would see each buffer fragment as a separate message.

* This patch running on the server will break negotiation
  with pre-peer-info clients.  Basically this means it will
  interoperate with any OpenVPN 3 version or OpenVPN 2.x
  version that includes the June 2010 commit "Implemented a
  key/value auth channel from client to server.
  Version 2.1.1i".
2016-05-09 21:39:04 -06:00
James Yonan
c033a93aa7 proto test : offset client/server reneg-sec to avoid
renegotiation collisions, and add note about new OpenSSL
error that can be triggered by such collisions.
2016-05-06 14:13:09 -06:00
James Yonan
0f40e47f9c cli.cpp : in log() method, use a mutex around std::cout
output, since log() can be called from multiple threads.
2016-04-09 00:57:21 -06:00
James Yonan
86d7729794 clievent : distinguish between 3 event categories
(instead of 2):

(a) ordinary events such as CONNECTING, CONNECTED,
(b) nonfatal errors such as TRANSPORT_ERROR that will
    automatically trigger a reconnect, and
(c) fatal errors such as AUTH_FAILED, that will be followed
    by a DISCONNECT

In ClientAPI::Event, added a new "fatal" boolean to indicate
when errors are fatal.

Added a new non-fatal event TUN_ERROR that triggers a
reconnect when errors are indicated in tunio.hpp.
2016-03-31 20:24:28 -06:00
James Yonan
081925f81b Removed gok script. 2016-03-19 02:00:26 -06:00
James Yonan
2b42b96312 Added IPv6 setting to ovpn3 client API via
ClientAPI::Config::ipv6 string:

  IPv6 preference
    no      -- disable IPv6, so tunnel will be IPv4-only
    yes     -- request combined IPv4/IPv6 tunnel
    default (or empty string) -- leave decision to server
2016-02-05 12:16:20 -07:00
James Yonan
426eb9d671 Autologin Sessions are now enabled via the client API
bool ClientAPI::Config::autologinSessions and default
to false.  Previously, the logic was hardcoded to true.

Autologin Sessions can be enabled in the cli.cpp wrapper
using the -a flag.
2016-02-04 11:39:44 -07:00
James Yonan
cd675664f0 Added build flag OPENVPN_DISABLE_EXPLICIT_EXIT to prevent
client from sending an Explicit Exit message to server on
disconnect.  Intended only for testing.
2016-01-27 14:16:03 -07:00
James Yonan
e3be7b998b Added gremlin option to client, controllable via
ClientAPI::Config::gremlinConfig string.

The gremlin option allows extra packet latency
or unreliability to be added to the tunnel.

The format of the option is a comma-separated list
of numerical parameters:

  send_delay_ms, recv_delay_ms, send_drop_prob, recv_drop_prob

Parameter description:

  send_delay_ms  : delay packets by n milliseconds before
                   transmission (UDP/TCP).
  recv_delay_ms  : delay received packets by n milliseconds
                   before processing them (UDP/TCP).
  send_drop_prob : drop sent packets with probability 1/n
                   (UDP only).
  recv_drop_prob : drop received packets with probability
                   1/n (UDP only).

Set any parameter to 0 to disable.

Gremlin parameters currently work with UDP and TCP
transport as documented above, but not for proxy transport.

Client must be built with the OPENVPN_GREMLIN flag to compile
gremlin functionality.

Command-line client can set the gremlin config
string using --gremlin or -G, for example:

  --gremlin=250,250,64,64

When using the above parameters, an extra 500 milliseconds
will be added to round-trip latency, and 1/64 sent or
received packets will be dropped.
2016-01-26 00:27:11 -07:00
James Yonan
8e9c059680 In command line client (cli.cpp), allow additional config
file directives to be specified on the command line after
the config file name.
2015-12-28 13:23:39 -07:00
James Yonan
1219720d26 In cli.cpp, fixed regression where command line arg
parser wasn't aligning correctly on the argv array.
2015-12-11 12:11:25 -07:00