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

2180 Commits

Author SHA1 Message Date
James Yonan
5befbd430f build: added CAP=1 -- build with libcap
libcap linkage is needed for use of the Linux capabilities API.

Signed-off-by: James Yonan <james@openvpn.net>
2019-07-17 10:53:46 -06:00
James Yonan
eb85ada21e signals: added trivial signal_name() function
Signed-off-by: James Yonan <james@openvpn.net>
2019-07-17 10:53:46 -06:00
James Yonan
f89013ef92 RunContext: don't try to catch SIGQUIT by default
SIGQUIT is better left wired to its standard use of core
dump generation.

Signed-off-by: James Yonan <james@openvpn.net>
2019-07-17 10:53:46 -06:00
James Yonan
e0ee540135 SessionIDType: added hash() method
Signed-off-by: James Yonan <james@openvpn.net>
2019-07-17 10:53:46 -06:00
James Yonan
f0e1f8aa42 logging: added basic components for logrotate
Added LogSetup, an abstract base class with a virtual method
reopen() that accomplishes the log file reopen.

Added RunContext::set_log_reopen() method that accepts
a LogSetup object and calls its reopen() method on
SIGHUP.

daemonize() and log_setup() methods in daemon.hpp
now return a LogSetup object.

Signed-off-by: James Yonan <james@openvpn.net>
2019-07-17 10:53:46 -06:00
James Yonan
fbb0c81f29 UMask: added UMaskDaemon, a umask context object appropriate for daemons
Signed-off-by: James Yonan <james@openvpn.net>
2019-07-17 10:53:46 -06:00
James Yonan
1c7bac90d9 build script: when building with DEBUG=1 on Linux, use -ggdb instead of -g
Signed-off-by: James Yonan <james@openvpn.net>
2019-07-17 10:53:46 -06:00
James Yonan
73cce80e43 OpenSSL: added openssl_reseed_rng() function
This function will reseed OpenSSL's random number generator
with entropy from /dev/urandom

Signed-off-by: James Yonan <james@openvpn.net>
2019-07-17 10:53:46 -06:00
James Yonan
25780cf798 OpenSSL: fixed some memory leaks in CipherContextGCM and TokenEncrypt
Signed-off-by: James Yonan <james@openvpn.net>
2019-07-17 10:53:46 -06:00
James Yonan
168dba95f5 OpenSSL: define OPENSSL_SERVER_SNI when OpenSSL version is at least 1.1
Also: minor error message clarification

Signed-off-by: James Yonan <james@openvpn.net>
2019-07-17 10:53:46 -06:00
James Yonan
84e78d8fed SNI: added OpenVPN client support for SNI (currently OpenSSL only)
For example, the following client directive will push the SNI name
"test@example.com" to the server:

  sni "test@example.com"

Signed-off-by: James Yonan <james@openvpn.net>
2019-07-17 10:53:46 -06:00
James Yonan
310766b270 build: added MTLS_DIST setting
MTLS_DIST=path -- use user-specified mbedTLS distribution

Signed-off-by: James Yonan <james@openvpn.net>
2019-07-17 10:53:46 -06:00
James Yonan
4eaa46a879 MbedTLS: added MBEDTLS_DISABLE_NAME_CONSTRAINTS preprocessor flag
This allows building a client against a generic mbedTLS library.

Signed-off-by: James Yonan <james@openvpn.net>
2019-07-17 10:53:46 -06:00
James Yonan
16226d1b05 OpenSSLSign: updated for OpenSSL 1.1
Signed-off-by: James Yonan <james@openvpn.net>
2019-07-17 10:53:46 -06:00
James Yonan
aed0678c96 SSL: added SNI::Metadata, an abstract base class for packaging app-specific SNI metadata in AuthCert
Signed-off-by: James Yonan <james@openvpn.net>
2019-07-17 10:53:46 -06:00
James Yonan
001b731fe2 SNI: create SNI namespace and rename SNIHandlerBase -> SNI::HandlerBase
Signed-off-by: James Yonan <james@openvpn.net>
2019-07-17 10:53:46 -06:00
Lev Stipakov
4bd5869305 README.rst: Make Windows-specific build steps up to date.
Signed-off-by: Lev Stipakov <lev@openvpn.net>
2019-07-17 17:45:47 +03:00
Lev Stipakov
ac365ee977 wintun: support for 0.4
Starting from 0.4, Wintun has removed
start padding and changed align to 4.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2019-07-16 11:08:27 +03:00
Lev Stipakov
9245056a2a wintun: support for 0.3
Starting from 0.3, Wintun expects client to pass
the same buffer for every read (and also write) call
with the same length, which at the first call is mapped
to kernel memory.

For read we have to disable triggering reads in parallel, since
each read uses own buffer.

For write, we perform "registration" - do the first call
with max length buffer filled by zeroes. Kernel will map buffer
and return error while attempting to read packets - this is expected.

Due to core buffer manipulations, buffer address passed to write call
varies, so we have to have a dedicated write buffer and perform copy
on every write.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2019-07-01 16:41:06 +03:00
Antonio Quartulli
b73d484950
mbedtls: throw exception on unsupported SSL:Const::PEER_CERT_OPTIONAL option
Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2019-06-25 12:01:52 +02:00
Antonio Quartulli
1d6bae4b5b
tcplinkcommon: bubble up real exception error
In case of error along the TCP RX path it is better to grab the error
coming with the exception and report it back up.

For this reason, catch ExceptionCode objects rather than std::exception
as the former carries the error code together with the text message.

Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2019-06-25 11:47:35 +02:00
Antonio Quartulli
c18c8bd156
tcpcli: ensure SSL Factory survives as long as TLS link
The SSL factory holds the config used by the link implementation during
various SSL operations.

For this reason we have to make the sure the Factory is not destroyed
(and thus the config) while the TLS link is alive.

Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2019-06-25 11:47:34 +02:00
Antonio Quartulli
4192193087
tls: parse and load TLS specific CA
Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2019-06-25 11:47:31 +02:00
Lev Stipakov
2a19b7fcff win/tuncli.hpp: fix Wintun padding calculation
Contrary to what Wintun doc says, end padding size
should be mod 16.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2019-06-20 10:34:38 +03:00
Lev Stipakov
44cb9f44da appveyor: make ReleaseOpenSSL default configuration
Signed-off-by: Lev Stipakov <lev@openvpn.net>
2019-06-20 10:34:38 +03:00
Lev Stipakov
5485de19a2 win/impersonate: refactor impersonate logic
Extend existing Impersonate class and move there
impersonate_as_system code from tunwin.hpp

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2019-06-20 10:34:38 +03:00
Lev Stipakov
29a655147b win/tunsetup.hpp: remove unneeded parameter
"wintun" is already a class member, no need to pass it to
class method.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2019-06-20 10:34:38 +03:00
Lev Stipakov
61794b0efd win: link OpenSSL dynamically
During Wintun performance testing it turned out that
dynamic linking provides better performance.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2019-06-20 10:34:38 +03:00
Lev Stipakov
e569b84465 win/tuncli.hpp: fix indentation
Signed-off-by: Lev Stipakov <lev@openvpn.net>
2019-06-20 10:34:38 +03:00
Lev Stipakov
374c57e708 frame_init.hpp: tweak wintun read buf size
According to tests, this gives the best performance (up to 2 Gbit/s)

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2019-06-20 10:34:38 +03:00
James Yonan
c3c45c9b38
tun: added Error::TUN_HALT for tun_error() signaling
Error::TUN_HALT, when passed up via tun_error(), now
sends an Explicit Exit Notify message before disconnect.

Signed-off-by: James Yonan <james@openvpn.net>
2019-06-19 18:35:20 +02:00
James Yonan
acd7af5e9a
RandomAPI: added randrange32() method
Signed-off-by: James Yonan <james@openvpn.net>
2019-06-19 18:35:20 +02:00
James Yonan
c1a7f8cc68
std::clamp() is useful but only available in C++17 and up, so we add our own clamp()
Signed-off-by: James Yonan <james@openvpn.net>
2019-06-19 18:35:19 +02:00
James Yonan
f8c71ef1ce
Minor change to Error::INACTIVE_TIMEOUT handler
Previously, the Error::INACTIVE_TIMEOUT handler in cliconnect.hpp
called graceful_stop() to ensure that the Explicit Exit Notify
message is sent to the server prior to disconnect.

But actually, the Explicit Exit Notify message is sent earlier
by the inactive_callback() method in cliproto.hpp, and the
graceful_stop() call in the Error::INACTIVE_TIMEOUT handler
is redundant and unnecessary.

So this patch changes the graceful_stop() call to stop().

Signed-off-by: James Yonan <james@openvpn.net>
2019-06-19 18:35:19 +02:00
James Yonan
3202ab5fce
OpenSSLSign: renamed OpenSSLPKI::X509Base to OpenSSLPKI::X509 to conform to changes in OpenSSLPKI
Signed-off-by: James Yonan <james@openvpn.net>
2019-06-19 18:21:03 +02:00
James Yonan
8d767febb5
ReachabilityBase: added virtual destructor
Signed-off-by: James Yonan <james@openvpn.net>
2019-06-19 18:21:03 +02:00
James Yonan
6a4826965f
MbedTLS: update json_override() prototype
Signed-off-by: James Yonan <james@openvpn.net>
2019-06-19 18:21:02 +02:00
James Yonan
bee0d8d187
SSL: added SSLConst::SEND_CLIENT_CA_LIST server-side flag and implemented for OpenSSL
If SEND_CLIENT_CA_LIST is enabled, we will call SSL_CTX_add_client_CA
for each CA specified in the config.  This will direct OpenSSL to
transmit a list of client CA names to the client so it can choose
an appropriate client certificate.

Signed-off-by: James Yonan <james@openvpn.net>
2019-06-19 18:21:02 +02:00
James Yonan
5eb39c1dea
AuthCert: save the SNI name
Signed-off-by: James Yonan <james@openvpn.net>
2019-06-19 18:21:02 +02:00
James Yonan
3b34449d0e
SSLAPI: auth_cert() can now be const
auth_cert() can now be const because OpenSSL rebuild_authcert()
is never called unless authcert has already been allocated,
making

  authcert.reset(new AuthCert());

redundant.  Once the above statement is removed,
rebuild_authcert() becomes const.

Signed-off-by: James Yonan <james@openvpn.net>
2019-06-19 18:21:02 +02:00
James Yonan
a672e91631
SNI server-side: support additional JSON configuration settings
Allow per-SNI JSON configurations to include more settings
such as:

* ca
* cert
* extra_certs
* key
* ns_cert_type
* remote_cert_tls
* tls_cert_profile
* tls_version_min

Signed-off-by: James Yonan <james@openvpn.net>
2019-06-19 18:21:01 +02:00
James Yonan
95e761f3cc
OpenSSL PKI cleanup
* Added C++11 features such as move constructor and move
  assignment method.

* Since these classes are already object wrappers, it's
  redundant to manage them via RC.

* Use the "::" prefix to denote OpenSSL symbols from the
  top-level namespace.

Signed-off-by: James Yonan <james@openvpn.net>
2019-06-19 18:21:01 +02:00
James Yonan
d5eb77c53c
AuthCert::Fail cleanup
* Make error code priority more rational, where the composite
  error code of the whole object (i.e. the get_code() return
  value) is the most severe error of any added failure.

* For clarity, rename OTHER to CERT_FAIL.

Signed-off-by: James Yonan <james@openvpn.net>
2019-06-19 18:21:01 +02:00
James Yonan
6e98b9aadc
SSLAPI: move PKType from SSLConfigAPI into standalone header to avoid dependency inversion
Attempting to build a standalone program that includes
openvpn/openssl/pki/pkey.hpp will fail because it depends
on the PKType enum in openvpn/ssl/sslapi.hpp which
is not explicitly included by pkey.hpp.

Rather than having pkey.hpp include sslapi.hpp (which
seems like a dependency inversion), put PKType into
its own header file.

Signed-off-by: James Yonan <james@openvpn.net>
2019-06-19 18:21:01 +02:00
James Yonan
bbae814864
OpenSSL: added SNI implementation
On the server side, we add the abstract base class
SNIHandlerBase to provide a hook (sni_hello) where
servers can inspect the SNI name given in the client
hello message and possibly return a different SSLFactoryAPI.

In other changes, we rename the ENABLE_SNI flag to
ENABLE_CLIENT_SNI to be clear that this flag only affects
the client-side SNI implementation.

We also add the NO_VERIFY_HOSTNAME flag on the client side
to allow the SNI name to be transmitted to the server
without requiring a match between the SNI name and the
common name or subject alternative name in the server
certificate.

Signed-off-by: James Yonan <james@openvpn.net>
2019-06-19 18:21:00 +02:00
James Yonan
5def1d23ab
OpenSSLContext: in constructor, removed redundant if statement
Signed-off-by: James Yonan <james@openvpn.net>
2019-06-19 18:21:00 +02:00
James Yonan
1a0747e783
OpenSSLContext: in constructor, consolidate sslopt fixed flags
Signed-off-by: James Yonan <james@openvpn.net>
2019-06-19 18:21:00 +02:00
James Yonan
eef9868816
OpenSSLContext::SSL::ssl_handshake_details(): include leaf-cert CN in details
Signed-off-by: James Yonan <james@openvpn.net>
2019-06-19 18:21:00 +02:00
James Yonan
f9631cd90f
AuthCert::Fail: use std::string for the reason string (instead of const char *)
Also added AuthCert::fail_str() method.

Signed-off-by: James Yonan <james@openvpn.net>
2019-06-19 18:20:59 +02:00
James Yonan
a17b77641f
OpenSSLPKI::X509: copy constructor doesn't need erase() and define X509::Ptr
Only the assignment constructor needs to erase the
current value.

Also, in keeping with convention, define X509::Ptr as
an alias for RCPtr<X509>.

Signed-off-by: James Yonan <james@openvpn.net>
2019-06-19 18:20:59 +02:00