Skip to content

Commit 8d47d9e

Browse files
committed
SSL test fixes
* fix CRL tests to work * regenerate certificates to be at least 2048 bit (fixes buster and rhel8 in buildbot) * update generate-ssl-cert.sh to generate crl files * make all SSL tests to use certificates generated in generate-ssl-cert.sh, remove unused certificates Backport from 10.4 9c60535
1 parent 20043cf commit 8d47d9e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+760
-1204
lines changed

mysql-test/disabled.def

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ events_time_zone : Test is not predictable as it depends on precise timi
1414
read_many_rows_innodb : Bug#11748886 2010-11-15 mattiasj report already exists
1515
mysql_embedded : Bug#12561297 2011-05-14 Anitha Dependent on PB2 changes - eventum#41836
1616
#show_explain : Psergey: random timeout in range-checked-for-each record query.
17-
ssl_crl_clients_valid : broken upstream
18-
ssl_crl : broken upstream
19-
ssl_crl_clrpath : broken upstream
2017
innodb-wl5522-debug-zip : broken upstream
2118
innodb_bug12902967 : broken upstream
2219
file_contents : MDEV-6526 these files are not installed anymore

mysql-test/include/have_openssl.inc

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
-- source include/have_ssl_communication.inc
2-
let $crllen=`select length(trim(coalesce(@@ssl_crl, ''))) + length(trim(coalesce(@@ssl_crlpath, '')))`;
3-
if (!$crllen)
4-
{
1+
if (`SELECT count(*) = 0 FROM information_schema.GLOBAL_VARIABLES WHERE
2+
VARIABLE_NAME = 'have_openssl' AND VARIABLE_VALUE = 'YES'`){
53
skip Needs OpenSSL;
64
}
7-

mysql-test/lib/generate-ssl-certs.sh

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,30 +10,49 @@ rm -rf demoCA
1010
mkdir demoCA demoCA/newcerts
1111
touch demoCA/index.txt
1212
echo 01 > demoCA/serial
13+
echo 01 > demoCA/crlnumber
1314

1415
# CA certificate, self-signed
1516
openssl req -x509 -newkey rsa:2048 -keyout cakey.pem -out cacert.pem -days 7300 -nodes -subj '/CN=cacert/C=FI/ST=Helsinki/L=Helsinki/O=MariaDB' -text
1617

1718
# server certificate signing request and private key. Note the very long subject (for MDEV-7859)
18-
openssl req -newkey rsa:1024 -keyout server-key.pem -out demoCA/server-req.pem -days 7300 -nodes -subj '/CN=localhost/C=FI/ST=state or province within country, in other certificates in this file it is the same as L/L=location, usually an address but often ambiguously used/OU=organizational unit name, a division name within an organization/O=organization name, typically a company name'
19+
openssl req -newkey rsa:2048 -keyout server-key.pem -out demoCA/server-req.pem -days 7300 -nodes -subj '/CN=localhost/C=FI/ST=state or province within country, in other certificates in this file it is the same as L/L=location, usually an address but often ambiguously used/OU=organizational unit name, a division name within an organization/O=organization name, typically a company name'
1920
# convert the key to yassl compatible format
2021
openssl rsa -in server-key.pem -out server-key.pem
2122
# sign the server certificate with CA certificate
22-
openssl ca -keyfile cakey.pem -days 7300 -batch -cert cacert.pem -policy policy_anything -out server-cert.pem -infiles demoCA/server-req.pem
23+
openssl ca -keyfile cakey.pem -days 7300 -batch -cert cacert.pem -policy policy_anything -out server-cert.pem -in demoCA/server-req.pem
2324

25+
# server certificate with different validity period (MDEV-7598)
26+
openssl req -newkey rsa:2048 -keyout server-new-key.pem -out demoCA/server-new-req.pem -days 7301 -nodes -subj '/CN=server-new/C=FI/ST=Helsinki/L=Helsinki/O=MariaDB'
27+
openssl rsa -in server-new-key.pem -out server-new-key.pem
28+
openssl ca -keyfile cakey.pem -days 7301 -batch -cert cacert.pem -policy policy_anything -out server-new-cert.pem -in demoCA/server-new-req.pem
29+
30+
# 8K cert
2431
openssl req -newkey rsa:8192 -keyout server8k-key.pem -out demoCA/server8k-req.pem -days 7300 -nodes -subj '/CN=server8k/C=FI/ST=Helsinki/L=Helsinki/O=MariaDB'
2532
openssl rsa -in server8k-key.pem -out server8k-key.pem
26-
openssl ca -keyfile cakey.pem -days 7300 -batch -cert cacert.pem -policy policy_anything -out server8k-cert.pem -infiles demoCA/server8k-req.pem
27-
28-
openssl req -newkey rsa:1024 -keyout client-key.pem -out demoCA/client-req.pem -days 7300 -nodes -subj '/CN=client/C=FI/ST=Helsinki/L=Helsinki/O=MariaDB'
29-
openssl rsa -in client-key.pem -out client-key.pem
30-
openssl ca -keyfile cakey.pem -days 7300 -batch -cert cacert.pem -policy policy_anything -out client-cert.pem -infiles demoCA/client-req.pem
33+
openssl ca -keyfile cakey.pem -days 7300 -batch -cert cacert.pem -policy policy_anything -out server8k-cert.pem -in demoCA/server8k-req.pem
3134

3235
# with SubjectAltName, only for OpenSSL 1.0.2+
3336
cat > demoCA/sanext.conf <<EOF
3437
subjectAltName=DNS:localhost
3538
EOF
36-
openssl req -newkey rsa:1024 -keyout serversan-key.pem -out demoCA/serversan-req.pem -days 7300 -nodes -subj '/CN=server/C=FI/ST=Helsinki/L=Helsinki/O=MariaDB'
37-
openssl ca -keyfile cakey.pem -extfile demoCA/sanext.conf -days 7300 -batch -cert cacert.pem -policy policy_anything -out serversan-cert.pem -infiles demoCA/serversan-req.pem
39+
openssl req -newkey rsa:2048 -keyout serversan-key.pem -out demoCA/serversan-req.pem -days 7300 -nodes -subj '/CN=server/C=FI/ST=Helsinki/L=Helsinki/O=MariaDB'
40+
openssl ca -keyfile cakey.pem -extfile demoCA/sanext.conf -days 7300 -batch -cert cacert.pem -policy policy_anything -out serversan-cert.pem -in demoCA/serversan-req.pem
41+
42+
# client cert
43+
openssl req -newkey rsa:2048 -keyout client-key.pem -out demoCA/client-req.pem -days 7300 -nodes -subj '/CN=client/C=FI/ST=Helsinki/L=Helsinki/O=MariaDB'
44+
openssl rsa -in client-key.pem -out client-key.pem
45+
openssl ca -keyfile cakey.pem -days 7300 -batch -cert cacert.pem -policy policy_anything -out client-cert.pem -in demoCA/client-req.pem
46+
47+
# generate crls
48+
openssl ca -revoke server-cert.pem -keyfile cakey.pem -batch -cert cacert.pem
49+
openssl ca -gencrl -keyfile cakey.pem -crldays 7300 -batch -cert cacert.pem -out server-cert.crl
50+
# we only want to have one certificate per CRL. Un-revoke server-cert.crl
51+
cp demoCA/index.txt.old demoCA/index.txt
52+
openssl ca -revoke client-cert.pem -keyfile cakey.pem -batch -cert cacert.pem
53+
openssl ca -gencrl -keyfile cakey.pem -crldays 7300 -batch -cert cacert.pem -out client-cert.crl
54+
55+
rm -fv crldir/*
56+
cp -v client-cert.crl crldir/`openssl x509 -in client-cert.pem -noout -issuer_hash`.r0
3857

3958
rm -rf demoCA

mysql-test/r/ssl-crl-revoked-crl.result

Lines changed: 0 additions & 1 deletion
This file was deleted.

mysql-test/r/ssl.result

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ have_ssl
44
1
55
SHOW STATUS LIKE 'Ssl_server_not_before';
66
Variable_name Value
7-
Ssl_server_not_before Apr 25 20:52:21 2017 GMT
7+
Ssl_server_not_before Jan 27 10:11:10 2019 GMT
88
SHOW STATUS LIKE 'Ssl_server_not_after';
99
Variable_name Value
10-
Ssl_server_not_after Apr 20 20:52:21 2037 GMT
10+
Ssl_server_not_after Jan 22 10:11:10 2039 GMT
1111
drop table if exists t1,t2,t3,t4;
1212
CREATE TABLE t1 (
1313
Period smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL,

mysql-test/r/ssl_cert_verify.result

Lines changed: 0 additions & 5 deletions
This file was deleted.

mysql-test/r/ssl_crl.result

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,5 @@
1-
# test --crl for the client : should connect
1+
# try logging in with a certificate not in the server's --ssl-crl : should succeed
22
Variable_name Value
3-
have_openssl YES
4-
have_ssl YES
5-
ssl_ca MYSQL_TEST_DIR/std_data/crl-ca-cert.pem
6-
ssl_capath
7-
ssl_cert MYSQL_TEST_DIR/std_data/crl-server-cert.pem
8-
ssl_cipher
9-
ssl_crl MYSQL_TEST_DIR/std_data/crl-client-revoked.crl
10-
ssl_crlpath
11-
ssl_key MYSQL_TEST_DIR/std_data/crl-server-key.pem
12-
# test --crlpath for the client : should connect
13-
Variable_name Value
14-
have_openssl YES
15-
have_ssl YES
16-
ssl_ca MYSQL_TEST_DIR/std_data/crl-ca-cert.pem
17-
ssl_capath
18-
ssl_cert MYSQL_TEST_DIR/std_data/crl-server-cert.pem
19-
ssl_cipher
20-
ssl_crl MYSQL_TEST_DIR/std_data/crl-client-revoked.crl
21-
ssl_crlpath
22-
ssl_key MYSQL_TEST_DIR/std_data/crl-server-key.pem
3+
Ssl_version TLS_VERSION
234
# try logging in with a certificate in the server's --ssl-crl : should fail
5+
ERROR 2026 (HY000): SSL connection error: sslv3 alert certificate revoked

mysql-test/r/ssl_crl_clients-valid.result

Lines changed: 0 additions & 24 deletions
This file was deleted.

mysql-test/r/ssl_crl_clients.result

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
# Test clients with and without CRL lists
22
############ Test mysql ##############
33
# Test mysql connecting to a server with a certificate revoked by -crl
4+
ERROR 2026 (HY000): SSL connection error: certificate revoked
45
# Test mysql connecting to a server with a certificate revoked by -crlpath
6+
ERROR 2026 (HY000): SSL connection error: certificate revoked
57
############ Test mysqladmin ##############
68
# Test mysqladmin connecting to a server with a certificate revoked by -crl
9+
mysqladmin: connect to server at 'localhost' failed
10+
error: 'SSL connection error: certificate revoked'
711
# Test mysqladmin connecting to a server with a certificate revoked by -crlpath
12+
mysqladmin: connect to server at 'localhost' failed
13+
error: 'SSL connection error: certificate revoked'

mysql-test/r/ssl_crl_clients_valid.result

Lines changed: 0 additions & 16 deletions
This file was deleted.

0 commit comments

Comments
 (0)