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

84 Commits

Author SHA1 Message Date
Arne Schwabe
3b46b64d13 Do not enforce DH parameters in TLS server mode
As also explained in OpenVPN 2.x commit bd9aa06feb4, Diffie Hellman
key exchanges can be optionally be disabled and OpenSSL will then use
only ECDH instead.

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2023-08-01 14:28:51 +02:00
Lev Stipakov
48863ace12
digestapi.hpp: pass libctx to digest api
Digest API calculates MD4/MD5 digests etc which
are deprecated. In order to use those one needs to
load OpenSSL legacy provider and EVP_MD_fetch() to
fetch digest implementation from all loaded providers.

EVP_MD_fetch() takes library context as an argument,
so we need to pass it there through the digest api stack.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2023-06-07 17:09:49 +02:00
Arne Schwabe
48f5adce94
Ensure that tlsVersionMinOverride does not lower TLS version
This ensure that client that want to set a miminum level of TLS
version do not accidentially lower the version when the profile already
requires a higher version.

Also make the tls version enum an enum class for better type safety.

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2023-03-29 23:14:15 +02:00
Arne Schwabe
171fd2f0af
Fix mbed TLS AEAD encrypt/decrypt with newer mbed TLS 2.x versions
Newer mbed TLS version changed the API. This fixes our usage of the API and
also removed the micro optimisation of reusing the buffer for plain and cipher
text.

It also adds a unit test to ensure the data is correctly encrypted/decrypted.

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2023-03-08 17:06:24 +01:00
David Sommerseth
dde1574596
Reformatting source code to new coding style
This is the result after running 'clang-format -i' on all C++ files and
headers, with the defined formatting rules in .clang-format.

Only the openvpn/common/unicode-impl.hpp has been excluded, as that is
mostly a copy of an external project.

Signed-off-by: David Sommerseth <davids@openvpn.net>
2023-01-18 19:24:15 +01:00
David Sommerseth
4996c38ed4
Merge lastest changes from Core v3.7.2 2022-12-14 17:34:29 +01:00
James Yonan
b0e6e842bd AuthCert: refactor certificate serial number into its own class AuthCert::Serial
Also, added support for parsing long serial numbers.

Signed-off-by: James Yonan <james@openvpn.net>
2022-11-29 18:23:46 -07:00
Arne Schwabe
3135d115a0 Replace throw() with noexcept and mark some exception constructors explicit
throw() is the same as noexcept(true), which is the same as noexpect.
(https://en.cppreference.com/w/cpp/language/noexcept_spec)

noexpect is more standard nowadays and less likely to create confusion.
Single argument constructors should be marked explicit so they do not
end up being acidentially called.
2022-11-16 17:22:09 +01:00
David Sommerseth
8c94a8f774
copyright: Update to 2022
Signed-off-by: David Sommerseth <davids@openvpn.net>
2022-09-29 12:00:26 +02:00
James Yonan
19201beb9f AuthCert: support up to 160 bit serial numbers
Previously, we only supported int64 serial numbers.

This change renames get_sn() method to serial_number_as_int64()
for code that cares about 64-bit serial numbers.

Signed-off-by: James Yonan <james@openvpn.net>
2022-09-21 23:00:13 -06:00
Arne Schwabe
811c8c78ca
Use xkey provider for external keys with OpenSSL 3.0
The xkey provider has been originally implemented by Selva Nair for
OpenVPN 2.x and he has agreed to allow me to reuse the provider for
OpenSSL 3.0

This brings the xkey provider to OpenSSL to Openvpn3. The xkey_provider.c
file is kept as close as possible to the original OpenVPN 2 source.
From xkey_helper only the parts that were needed were picked up and used
in xkey.hpp.

This also changes the requests for clients wanting to implementing the
API, generally making them more work (adding PSS/PKCS1 padding and hashing)
but this is a good thing since especially external keys/HSM often do not
like doing raw signatures and often require to do padding/hashing themselves.

This commit also updates the test client's EPKI implementation to work
with the new requirements of the new API.

Since most of OpenVPN3's code base assumes having only one compilation unit
and the xkey_provider.c, this commit introduces the ENABLE_EXTERNAL_PKI
define. Only if this is set external key support is supported (and the
xkey_provider.c compilation unit needed).

This commit furthermore removes the pragma statements from extpki.hpp that
supressed warnings when being compiled with OpenSSL 3.0+ as this is header file
longer compiled with OpenSSL 3.0+. (Technically xkey is >= 3.0.1 but we have
no target that is OpenSSL 3.0.0).

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2022-06-08 22:41:36 +02:00
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