[MDEV-22221] Official binary compiled with WolfSSL doesn't support TLS 1.3 and AES-GCM cipher Created: 2020-04-11  Updated: 2021-07-21  Resolved: 2021-07-21

Status: Closed
Project: MariaDB Server
Component/s: SSL
Affects Version/s: 10.4.12
Fix Version/s: 10.4.21, 10.5.12, 10.6.4

Type: Bug Priority: Major
Reporter: Bohan Yang Assignee: Vladislav Vaintroub
Resolution: Fixed Votes: 0
Labels: None
Environment:

Tested on:
Windows 10 1809 17763.1131 Official 10.4.12 MSI installer
Fedora 31 in Docker on Debian 10 Linux 4.19.0 Official 10.4.12 Binary tarball
(wolfSSL Version 4.3.0)


Issue Links:
Duplicate
is duplicated by MDEV-25799 tls_version=TLSv1.3 does not work wit... Closed

 Description   

Config 1:

ssl_cert=/etc/mysql/ssl/db.crt
ssl_key=/etc/mysql/ssl/db.key
tls_version=TLSv1.3

OpenSSL 1.1.1 s_client test:

openssl s_client -connect 127.0.0.1:3306 -status -tlsextdebug -starttls mysql < /dev/null 2>&1
CONNECTED(00000003)
140674569278592:error:1408F10B:SSL routines:ssl3_get_record:wrong version number:../ssl/record/ssl3_record.c:332:

mysql client test:

/usr/local/mysql/bin/mysql -h 127.0.0.1 -u root --ssl-ca=/etc/ssl/certs/ca-bundle.crt
ERROR 2026 (HY000): SSL connection error: A packet with illegal or unsupported version was received.

(Always fail if only TLS 1.3 is enabled)


Config 2

ssl_cert=/etc/mysql/ssl/db.crt
ssl_key=/etc/mysql/ssl/db.key
tls_version=TLSv1.2
ssl_cipher=ECDHE-RSA-AES256-GCM-SHA384

mysqld error log

2020-04-11 15:03:03 0 [Warning] Failed to setup SSL
2020-04-11 15:03:03 0 [Warning] SSL error: Failed to set ciphers to use


While all these configs work perfectly for Official DEB package compiled with OpenSSL 1.1.1



 Comments   
Comment by Daniel Black [ 2020-04-12 ]

btw nice use of openssl s_client, I hadn't realised they had added --starttls mysql

Comment by Daniel Black [ 2020-04-13 ]

PR complete.

WolfSSL TLSv1.3 when a client provides a certificates will segfault until https://github.com/wolfSSL/wolfssl/pull/2901 is applied. As a test of this. run main.ssl_8k_key test with --tls-version=TLSv1.3.

There are TLSv1.3 test gaps however I've added mysqltest support to TLS-VERSION in the PR.

FP_MAX_BITS is twice the HAVE_FFDHE_3072 and clang/x86_64 gets the higher numbers enabled so compiles and tests pass on gcc/x86_64 and clang(8)/x86_64 (Linux only tested). Bohan's test cases above also pass correctly.

Comment by Vladislav Vaintroub [ 2020-04-14 ]

danblack, is PR really complete?

I'm trying to use the TLSv1.3 that supposedly would work, with WolfSSL

C:\work\10.4\xxx\mysql-test>perl mysql-test-run.pl openssl_1 --mysqld=--tls-version=TLSv1.3
<skip>
 
CURRENT_TEST: main.openssl_1
mysqltest: At line 27: query 'connect  con1,localhost,ssl_user1,,,,,SSL' failed: 2026: SSL connection error: . The message received was unexpected or badly formatted. Error 0x80090326(SEC_E_ILLEGAL_MESSAGE)
 
The result from queries just before the failure was:
set local sql_mode="";
set global sql_mode="";
drop table if exists t1;
create table t1(f1 int);
insert into t1 values (5);
grant select on test.* to ssl_user1@localhost require SSL;
grant select on test.* to ssl_user3@localhost require SUBJECT "/C=FI/ST=Helsinki/L=Helsinki/O=MariaDB/CN=client";
grant select on test.* to ssl_user4@localhost require SUBJECT "/C=FI/ST=Helsinki/L=Helsinki/O=MariaDB/CN=client" ISSUER "/CN=cacert/C=FI/ST=Helsinki/L=Helsinki/O=MariaDB";
grant select on test.* to ssl_user5@localhost require SUBJECT "xxx";
flush privileges;

Comment by Daniel Black [ 2020-04-19 ]

 
build-mariadb-server-10.4]$ perl mysql-test/mysql-test-run.pl openssl_1 --mysqld=--tls-version=TLSv1.3
Logging: /home/dan/repos/mariadb-server-10.4/mysql-test/mysql-test-run.pl  openssl_1 --mysqld=--tls-version=TLSv1.3
vardir: /home/dan/repos/build-mariadb-server-10.4/mysql-test/var
Checking leftover processes...
Removing old var directory...
 - WARNING: Using the 'mysql-test/var' symlink
Creating var directory '/home/dan/repos/build-mariadb-server-10.4/mysql-test/var'...
Checking supported features...
MariaDB Version 10.4.13-MariaDB
 - SSL connections supported
 - binaries built with wsrep patch
Collecting tests...
Installing system database...
 
==============================================================================
 
TEST                                      RESULT   TIME (ms) or COMMENT
--------------------------------------------------------------------------
 
worker[1] Using MTR_BUILD_THREAD 300, with reserved ports 16000..16019
main.openssl_1                           [ pass ]    469
--------------------------------------------------------------------------
The servers were restarted 0 times
Spent 0.469 of 6 seconds executing testcases
 
Completed: All 1 tests were successful.

So definitely need the more tls1.3 tests in the suite. along with the failing 8k test (currently generating a duplicate free, waiting on wolfssl upstream for some clue as to why).

Comment by Vladislav Vaintroub [ 2020-04-19 ]

Alright, on Windows the schannel-based client does not do TLSv1.3
Windows 10 has some kind of experimental support, but enabling TLSv1.3v ia registry, plus removing the restrictions on protocols C/C, does not help much . Looks like we have to wait for official support of that, on Windows.

Comment by Daniel Black [ 2020-05-02 ]

On the non-windows server side, the openssl build has TLSv1.3 now. So should we aim to deliver that with wolfssl while disabling the TLSv1.3 on Windows?

Wolfssl TLSv1.3 8k client certificate support just got fixed upstream (https://github.com/wolfSSL/wolfssl/pull/2933).

So options:

I looked for a hook that could detect a 8k client certificate however CallbackRsaVerify was called too late.

Which mariadb release branch should be targeted for these changes?

Comment by Vladislav Vaintroub [ 2020-05-02 ]

Do all openssl builds support TLSv1.3?

Usually, we take major releases. If there is something truly important, I guess an exception is possible.

The submodule changes go into lowest applicable version, which would be 10.4

Comment by Daniel Black [ 2020-05-03 ]

note: openssl-1.1.1 introduced tlsv1.3 - https://www.openssl.org/blog/blog/2017/05/04/tlsv1.3/ (and https://github.com/openssl/openssl/blob/master/CHANGES.md#changes-between-110i-and-111-11-sep-2018).

Comment by Otto Kekäläinen [ 2020-10-27 ]

Side note: Downstream in Debian the release team finally gave us premission to use OpenSSL and thus WolfSSL (ssl=bundled) was now dropped for MariaDB 10.5 in Debian and OpenSSL introduced, and along with it support for TLSv1.3. Ref: https://salsa.debian.org/mariadb-team/mariadb-10.5/-/commit/ca2574aa88434d1c49456c677b7dcb904902daaf

Comment by Vladislav Vaintroub [ 2021-06-09 ]

I allowed AES-GCM on WolfSSL now, but TLS1.3 will have to wait longer.
this is because the last version we currently use (4.6.0) has high severity vulnerability in TLSv1.3 support (CVE-2021-3336) , and 4.7 was not compilable , when we tried to use it.

Generated at Thu Feb 08 09:13:06 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.