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

73 Commits

Author SHA1 Message Date
Arne Schwabe
5ace7b8ad4
Add missing override keywods in SSLContext
Signed-off-by: Arne Schwabe <arne@openvpn.net>
2021-11-12 20:59:43 +01:00
Arne Schwabe
7897c3bd7e
Rename OPENVPN_USE_TLS_MD5 to OPENVPN_ALLOW_INSECURE_CERTPROFILE
With OpenSSL 3.0 the name with MD5 no longer makes sense as it affects
not only MD5 but also SHA1 and number of other settings. So replace the
define with a more fitting name.

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2021-11-12 20:58:44 +01:00
Arne Schwabe
2983e1a886
[OSSL 3.0] Allow loading of legacy provider in OpenSSL 3.0
Signed-off-by: Arne Schwabe <arne@openvpn.net>
2021-11-12 20:58:36 +01:00
Arne Schwabe
708be87c72
[OSSL 3.0] Implement using a library context for OpenSSL 3.0
This allows use to load non default providers while also not touching
the default library context. THis is necessary to have profile with and
without legacy library for example

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2021-11-12 20:58:30 +01:00
Arne Schwabe
9061cd4405
[OSSL 1.1/3.0] Replace custom TLS1 PRF with library function
We currently use a custom function to implement the TLS1 PRF function.
Deprecate the custom function and use the function of the OpenSSL
library instead where available.

This also allows us to work on system that run in FIPS mode and no
longer allow using MD5/SHA1 without workarounds.

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2021-11-12 20:57:28 +01:00
Arne Schwabe
fcd8b880bc [OSSL 3.0] Use fetch methods to retrieve EVP_CIPHER
In OpenSSL 3.0 algorithm are no longer guaranteed to be present if the
nid/method is present. Use the udpdated EVP_CIPHER_fetch API to fetch
the ciphers instead as these will return nullptr if the algorithm is
not available.

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2021-11-12 14:27:12 +01:00
Arne Schwabe
2152d2ab07
Increase minimum default TLS level to 1.2
Various components like HTTP clients etc already overwrite this
to TLS 1.2 anyway and this can be still lower to 1.0 by explicitly
overriding it.

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2021-05-05 19:44:53 +02: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
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
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
2141e23ecd Implement tls-groups option to specify eliptic curves/groups
OpenSSL 1.1+ by default only allows signatures and key exchange from the
default list of X25519:secp256r1:X448:secp521r1:secp384r1. Since in
TLS1.3 key exchange is independent from the signature/key of the
certificates, allowing all groups per default is not a sensible choice
anymore and the shorter lister is reasonable.

However, when using certificates with exotic curves the signatures of
this certificates will no longer be accepted. This option allows to
modify the list for these corner cases.

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2020-05-13 16:23:36 +02:00
David Sommerseth
3fbe0a2701
Update copyrights
Signed-off-by: David Sommerseth <davids@openvpn.net>
2020-03-18 19:37:32 +01:00
Arne Schwabe
941104cf49
Implement supporting IANA cipher names in tls-cipher and unit tests
Signed-off-by: Arne Schwabe <arne@openvpn.net>
2020-03-11 19:51:37 +01:00
Arne Schwabe
6e463ca1f4
Implement tls-cipher and tls-ciphersuite
Signed-off-by: Arne Schwabe <arne@openvpn.net>
2020-03-11 19:51:37 +01:00
Arne Schwabe
9c547ba3ff
Remove force_aes_cbc_ciphersuites option
This option has been very likely been to fix some incompatibilities
between some TLS libraries. But nobody really remember what it fixes
and its usage today is questionable. So remove the option instead
of supporting an option we cannot even test anymore.

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2020-03-11 19:51:18 +01:00
Arne Schwabe
a1250b9bed Announce Chacha20-poly1305 in IV_CIPHER if supported
Signed-off-by: Arne Schwabe <arne@openvpn.net>
2020-02-18 18:50:27 +01:00
Arne Schwabe
80399075d4 Implement CHACHA20-Poly1305 support for data channel
This also changes the mbed TLS implementation from using the AES GCM
specific API to the generic AEAD API in mbed TLS. As result we can
refactor the commonly used parts of AEAD and normal cipher into a
common class.

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2020-02-18 18:50:27 +01:00
Arne Schwabe
424d9b34af Rename GCM classes and files to AEAD
Signed-off-by: Arne Schwabe <arne@openvpn.net>
2020-02-18 18:50:27 +01:00
David Sommerseth
d0ab53a5d5
Merge changes applied to coming Core release 2019-12-10 15:20:49 +01:00
Arne Schwabe
97881b5c4f Require internal json for sslctx json functions
These functions require methods that are not available if
jsoncp is used as json library

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2019-11-27 16:03:44 +01:00
David Sommerseth
7bd55e0a7b
mbedtls: Add support for --verify-x509-name
This is the mbed TLS counterpart of the OpenSSL change in
commit c069b7cf5fb9ba47.

Signed-off-by: David Sommerseth <davids@openvpn.net>
2019-11-08 10:00:45 +01:00
David Sommerseth
fc060bd317
mbedtls: Move x509_get_subject() and x509_get_common_name() to an independent file
This is the mbed TLS counter part to the OpenSSL change in
commit e0fd92f30756.  These two methods are generic and not
tied to the MbedTLSContext in any particular way.

This is needed to be able to add a unit test for the x509_get_*()
functions.

Signed-off-by: David Sommerseth <davids@openvpn.net>
2019-11-08 10:00:43 +01:00
David Sommerseth
7900c71f5c
mbedtls: Add missing include file in x509cert.hpp
This file uses BufferAllocated, which is defined in
openvpn/buffer/buffer.hpp

Signed-off-by: David Sommerseth <davids@openvpn.net>
2019-11-08 10:00:42 +01:00
Arne Schwabe
4d18aaeb88 Fix LLVM warnings reported during OS X build
const modifies on primitive return types (int, bool, etc.) do not
do anything and Clang complains about these.

Zero initialisation in C++ is done by = {} or class().

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2019-08-29 16:59:33 +02:00
Arne Schwabe
23959fa705 Add reporting of IV_SSL_VER
This information is only send if push-peer-info is enabled. It is meant
to have an easy way for centrally adminstrated to spot clients using
outdated SSL libraries.
2019-08-29 16:33:05 +02: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
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
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
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
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
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
David Sommerseth
025c7bad88
mbedtls/sslctx: Fix missing override in virtual methods
The Clang++ compiler is not happy about this missing declaration on
virtual methods, which is a fair complaint.

Signed-off-by: David Sommerseth <davids@openvpn.net>
2019-05-16 15:12:47 +02:00
James Yonan
6cb3243681
mbedTLS: ssl() method accepting hostname should check if it is null
Signed-off-by: James Yonan <james@openvpn.net>
2019-05-16 14:50:06 +02:00
James Yonan
964d2cd428
SSL layer: added did_full_handshake() method and implemented for OpenSSL
Returns true if we did a full SSL handshake/negotiation.
or false for cached, reused, or persisted sessions.

Signed-off-by: James Yonan <james@openvpn.net>
2019-05-16 14:50:06 +02:00
James Yonan
162eeaa485
SSL layer: added RFC 5077 TLS session resumption ticket support
This is an initial client and server-side implementation
for OpenSSL 1.0.2.

Note that this functionality is intended for use with
HTTP sessions, and should not be used with the OpenVPN
protocol.

Signed-off-by: James Yonan <james@openvpn.net>
2019-05-16 14:50:06 +02:00
James Yonan
18f5f4d1b5
SSLConfigAPI: remove set_enable_renegotiation()
Removed set_enable_renegotiation from SSLConfigAPI and underlying
SSL implementations (OpenSSL, MbedTLS) since we are not currently
using it and TLS 1.3 standardizes on a session ticket model rather
than server-side session caching.

Signed-off-by: James Yonan <james@openvpn.net>
2019-05-15 18:56:48 +02:00
Arne Schwabe
9768562a01 OpenSSL 1.1: Add argument to external sign to specify algorithm
In TLS 1.3 the RSA-PSS padding is required in addition to the
traditional PKCS1 padding used in TLS 1.2 and below. Add an
argument to the external sign function to signal what padding
is required. As quirkyness OpenSSL calls out requesting a NONE
padding instead of RSA-PASS.

We might need to move from RSA_method to EVP_PKEY_method in the
future.

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2019-04-15 15:47:22 +02:00
Arne Schwabe
073b3993f4 Fix commit 8b22a7b2 (mbed TLS compatibility)
The commit 8b22a7b2 had two mistakes:

Accidentally moving the #endif to the wrong line during reformat.
Forgetting to include mbedtls/version.h so the version check was always
false.
2019-02-12 14:04:40 +01:00
Arne Schwabe
8b22a7b209 Fix compatibility with mbed TLS < 2.7.0 2019-02-11 11:18:58 +01:00
Antonio Quartulli
54a97b3814
ssl: add support for encoding/decoding PEM format
Add PEMAPI to allow OpenVPN core to encode/decode PEM
format using {mbed,Open}SSL API.

Needed to decode tls-crypt-v2 keys.

Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2018-12-06 09:19:21 +10:00
Arne Schwabe
a7b923e1ef Fix logic inversion from commit 2de9aebc
In commit 2de9aebc74 the commit introduced
checking the return value of mbetls_sha1_ret. Unfortenately, I got the
condition flipped.
2018-11-26 10:30:59 +00:00
Arne Schwabe
2de9aebc74
Replace deprecated mbedtls_sha1 with mbedtls_sha1_ret
This is super unlikely to fail but be better safe than sorry.

The function needs mbed TLS 2.7.0 which should be fine for every
still supported platform of us.
2018-11-07 20:56:34 +01:00
Arne Schwabe
6d12c9cc29 Refuse external pki with non RSA keys
Without this patch you get still specify a client EC certificate and
connect to a RSA server. The connection will be established until the
external pki sign will fail in "interesting" ways.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
2018-11-07 18:32:36 +01:00
Arne Schwabe
02d2a7975e Fix multiple inclusion of OpenVPN3 header with OPENPVN_EXTERN
To bundle ptcore and openvpncli into the same shared library for
OpenVPN Connect, the two libraries need both to include OpenVPN (or
parts of it).

Ptcore defines OPENVPN_EXTERN as extern to define the symbols as extern
in that library but a few places are missing proper weak symbol (inline)
or extern declaration.
2018-07-05 15:38:48 +02:00
Antonio Quartulli
f1ef079f0d
[OVPN3-237] SSLAPI: simplify PK types
Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2018-06-29 17:04:47 +08:00
Lev Stipakov
35bbca799d Merged in OVPN3-184-generate-warning (pull request #1)
OVPN3-184 Name Constraints

Approved-by: Antonio Quartulli <antonio@openvpn.net>
Approved-by: James Yonan <james@openvpn.net>
2018-04-25 18:10:21 +00:00
Lev Stipakov
08d72bd76d [OVPN3-184] mbedtls: handle Name Constraints
Introduce profile flag "allow-name-constraints".

mbedTLS doesn't support x509v3 'Name Constrains'
extension. To allow client to connect, make mbedTLS
not to fail on this extension and drop a warning to UI.

This depends on "Enable allowing unsupported critical extensions in runtime"
patch to mbedTLS.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2018-04-19 11:11:39 +03:00
Antonio Quartulli
37dc863783
[OVPN3-169] mbedTLS: implement write_ciphertext_unbuffered() function
Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2018-04-19 12:10:00 +08:00
James Yonan
37d848ca20
Log lines from C++ exceptions should contain the text "exception"
This makes it easier to scan log files for exceptions.

Signed-off-by: James Yonan <james@openvpn.net>
2018-03-26 23:58:35 +08:00