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

1532 Commits

Author SHA1 Message Date
James Yonan
bc406975b0 android : updated javacli/build-android for mbedTLS 2017-03-18 12:24:54 -06:00
James Yonan
f5f68bfcf4 android : build scripts now build mbedTLS instead of PolarSSL 2017-03-18 12:24:54 -06:00
James Yonan
8a0308d8d0 javacli : add Swig-generated files to .gitignore 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
fb5f494735 Mac build scripts : update for mbedTLS 2017-03-18 12:24:54 -06:00
James Yonan
c51eb86b39 dependencies : updated dependency versions. 2017-03-18 12:24:54 -06:00
James Yonan
3b399a6101 asio : the latest Asio master on Github has deprecated
user-defined service objects.  This commit attempts
to work around that but requires a specially patched
version of Asio that includes the virtual
async_connect_post_open() method.
2017-03-18 12:24:54 -06:00
James Yonan
1f69ae37e7 asio : updates for API changes to "work" object in latest github master.
The asio::io_context::work class has been replaced by a new
class having somewhat different and more verbose
semantics.

We create our own class AsioWork based on the new class
asio::executor_work_guard<asio::io_context::executor_type>
that implements the semantics of the original
asio::io_context::work class.
2017-03-18 12:24:54 -06:00
James Yonan
ad1989a547 asio: deal with symbol renaming in latest github master
mutable_buffers_1 -> mutable_buffer
const_buffers_1 -> const_buffer

This patch is a granularization of a patch by David Sommerseth
<davids@openvpn.net> where only the above renames are included.
2017-03-18 12:24:54 -06:00
David Sommerseth
ede022e04e compress: Update lz4 implementation to new API
As of LZ4 v1.7, the LZ4_compress() function is deprecated and
is to be replaced with LZ4_compress_default().

This new function adds an extra argument which declares the size
of the destination buffer.  In addition, if the result is 0, the
result buffer is not to be trusted as the compression failed.

Signed-off-by: David Sommerseth <davids@openvpn.net>
2017-03-18 12:24:54 -06:00
James Yonan
ba47bd6f05 build script : OSSL=1 option on Linux will link
with system 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
ee30d62a4d mbedTLS: Port from polarssl-1.3 to mbedtls-2.3 (file renames)
This patch renames openvpn/polarssl -> openvpn/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
James Yonan
7b15020ae6 OpenSSL : clear the OpenSSL error stack in OpenSSLContext::SSL
destructor.  Not doing so can cause this error:

  OpenSSLContext::SSL::read_cleartext: BIO_read failed, cap=400 status=-1: error:140E0197:SSL routines:SSL_shutdown:shutdown while in init

to wrongly implicate the next SSL session.
2017-03-18 12:24:54 -06:00
James Yonan
24c64593ed OpenVPN 3 client : check that state->session is non-NULL
before calling dont_restart().  Not doing so can potentially
cause a segfault.
2017-03-18 12:24:54 -06:00
James Yonan
ab910df574 Linux build : use ordinary gcc, g++ commands rather than
using explicit GCC 5 commands such as gcc-5, g++-5.
2017-03-18 12:24:54 -06:00
James Yonan
b7759986cd Linux build : no longer build OpenSSL as a private
dependency, use distro version.
2017-03-18 12:24:54 -06:00
James Yonan
10a722de90 LinuxGW46 : added dev() method. 2017-03-18 12:24:54 -06:00
James Yonan
7ee5768d1d URL::Parse : added loose_validation flag. 2017-03-18 12:24:54 -06:00
James Yonan
83dbe7dc1e URL::Parm : added get_num_required() and
get_string_required() methods.
2017-03-18 12:24:54 -06:00
James Yonan
1fd81ebf96 random : because the RandomAPI interface now supports
both cryptographic and non-cryptographic algorithms, as
a failsafe, add a new virtual method assert_crypto()
that will throw an exception if the algorithm is not
crypto strength.  assert_crypto() should now be called
before any RNG is used for crypto purposes.
2017-03-18 12:24:54 -06:00
James Yonan
75df3ba09d Mac network reachability : use ReachabilityViaInternet instead of
ReachabilityViaWiFi, as it appears to solve issue of reachability
flapping on OSX 10.12 (Sierra).
2017-03-18 12:24:54 -06:00
James Yonan
4de93d5f65 write_binary_atomic() changes:
1. now uses write_binary_unix() for performance
2. use a leading '.' in generated temporary filenames
2017-03-18 12:24:54 -06:00
James Yonan
ee91c99d40 library : added set of file read/write helper methods
optimized for unix (openvpn/common/fileunix.hpp).
2017-03-18 12:24:54 -06:00
James Yonan
8e40fade53 sslchoose : define OPENVPN_LOG_SSL(x) if it is
not already defined, to avoid compile errors in
subsequently included files.
2017-03-18 12:24:54 -06:00
James Yonan
260e9436f6 URL::decode() optimization : reserve output string. 2017-03-18 12:24:54 -06:00
James Yonan
1deedbaef7 HashString : added void final(Buffer& output) method. 2017-03-18 12:24:54 -06:00
James Yonan
281d08599a string : added ends_with_crlf(),
add_trailing_unless_empty_copy(), and is_alphanumeric().

Implementation changes to ends_with(), trim_crlf(),
and is_word().
2017-03-18 12:24:54 -06:00
James Yonan
295a999fef stat : added file_mod_time_nanoseconds() and
file_mod_time_milliseconds().
2017-03-18 12:24:54 -06:00
James Yonan
03d3318482 ScopedFD : added close_with_errno() 2017-03-18 12:24:54 -06:00
James Yonan
02953d8797 path : added varargs join() 2017-03-18 12:24:54 -06:00
James Yonan
d095771529 hexstr : added class RenderHexByte 2017-03-18 12:24:54 -06:00
James Yonan
fa75e9f98e enum_dir : for consistency, libc function calls should
always include a "::" prefix before the function name.
2017-03-18 12:24:54 -06:00
James Yonan
8cbce45545 buf_read : removed accidently-committed debugging code. 2017-03-18 12:24:54 -06:00
James Yonan
f0cfa5e18f Buffer : added is_zeroed() method. 2017-03-18 12:24:54 -06:00
James Yonan
0b662bc284 C++ coding : for consistency, const strings should be passed as
const std::string&, not const std::string
2017-03-18 12:24:54 -06:00
James Yonan
8c3c763789 protocol : allow client UI to post client -> server control
channel messages using the new

  ClientAPI::OpenVPNClient::post_cc_msg()

method:

  // post control channel message
  void post_cc_msg(const std::string& msg);
2017-03-18 12:24:54 -06:00
James Yonan
81c9d74f29 server : provide a management layer callback
info_request() for INFO messages posted by client
to OpenVPN control channel.
2017-03-18 12:24:54 -06:00
James Yonan
31ae0e83b8 core version : updated to 3.1.2 2017-03-18 12:24:54 -06:00
James Yonan
791344ba0f URL::Parm : added get_num(), get_bool(), get_string()
methods.
2017-03-18 12:24:54 -06:00
James Yonan
18eb8c7646 daemonize/log_setup : Added optional SetUserGroup parameter
to allow chown of log file.
2017-03-18 12:24:54 -06:00
James Yonan
ac6c330dc7 UserGroup : Added strict flag to constructor to allow for
construction even when user/group lookup fails.

Updated calls to std::strerror() to use a saved version
of errno.

Added chown(), gid(), and additional defined() methods.

Use uid_t as the return type for uid().
2017-03-18 12:24:54 -06:00
James Yonan
83d575893f string::join : if tail is true, don't append a
lone delimiter char to return string if passed
string vector is empty.
2017-03-18 12:24:54 -06:00
James Yonan
9c0397ebd3 Added Relay capability, a kind of proxy function similar
to HTTP CONNECT but implemented over the OpenVPN protocol.

1. Client connects to relay server as if it were connecting
   to an ordinary OpenVPN server.

2. Client authenticates to relay server using its client
   certificate.

3. Client sends a PUSH_REQUEST method to relay server which
   then replies with a RELAY message instead of PUSH_REPLY.

4. On receiving the RELAY message, the client attempts to
   reconnect using the existing transport socket.  The
   server will proxy this new connection (at the transport
   layer) to a second server (chosen by the relay server)
   that is the target of proxy.

5. The client must establish and authenticate a new session
   from scratch with the target server, only reusing the
   transport layer socket from the original connection to
   the relay server.

6. The relay acts as a man-in-the-middle only at the
   transport layer (like most proxies), i.e. it forwards
   the encrypted session between client and target server
   without decrypting or having the capability to decrypt
   the session.

7. The client is designed to protect against potentially
   untrusted or malicious relays:

   (a) The client never transmits the target server
       username/password credentials to the relay server.

   (b) The relay forwards the encrypted OpenVPN session
       between client and target server without having
       access to the session keys.

   (c) The client configuration has a special directive
       for relay server CA (<relay-extra-ca>) and relay
       server tls-auth key (<relay-tls-auth>) to allow
       for separation of TLS/crypto configuration between
       relay and target servers.

   (d) The client will reject any PUSH_REPLY messages
       from the relay itself to prevent the relay from
       trying to establish a tunnel directly with the
       client.

Example configuring a client for relay:

  # remote addresses point to the relay server
  remote ... 1194 udp
  remote ... 443 tcp

  # include all other directives for connecting
  # to the target server

  # enable relay mode
  relay-mode

  # constrain the relay server's cert type
  relay-ns-cert-type server

  # include extra CAs that validate the relay
  # server cert (optional).
  <relay-extra-ca>
  -----BEGIN CERTIFICATE-----
  . . .
  -----END CERTIFICATE-----
  </relay-extra-ca>

  # specify the TLS auth key for the relay server
  relay-key-direction 1
  <relay-tls-auth>
  -----BEGIN OpenVPN Static key V1-----
  . . .
  -----END OpenVPN Static key V1-----
  </relay-tls-auth>
2017-03-18 12:24:54 -06:00
James Yonan
c3dc14f3a0 IPv4::Addr : cosmetic fix -- removed spurious ';' 2017-03-18 12:24:54 -06:00
James Yonan
3874a30818 ovpncli.hpp : use C++11 move semantics for KeyValue
constructor.
2017-03-18 12:24:54 -06:00
James Yonan
fad49b2059 Linux : Added class LinuxRoute for adding/deleting
routes on Linux using AF_NETLINK socket.
2017-03-18 12:24:54 -06:00
James Yonan
6cb6715505 linux netconf : deleted obsolete file. 2017-03-18 12:24:54 -06:00
James Yonan
3b57e1995e IP::Addr : added family(), size_bytes(), and
to_byte_string_variable() methods.
2017-03-18 12:19:39 -06:00