[nginx-tests] Tests: improved compatibility when using recent "o...
Maxim Dounin
mdounin at mdounin.ru
Sun May 5 21:05:01 UTC 2024
details: http://freenginx.org/hg/nginx-tests/rev/b5036a0f9ae0
branches:
changeset: 1974:b5036a0f9ae0
user: Maxim Dounin <mdounin at mdounin.ru>
date: Mon May 06 00:04:26 2024 +0300
description:
Tests: improved compatibility when using recent "openssl" app.
Starting with OpenSSL 3.0, "openssl genrsa" generates encrypted keys
in PKCS#8 format instead of previously used PKCS#1 format. Further,
since OpenSSL 1.1.0 such keys are using PBKDF2 hmacWithSHA256.
Such keys are not supported by old SSL libraries, notably by OpenSSL
before 1.0.0 (OpenSSL 0.9.8 only supports hmacWithSHA1) and by BoringSSL
before May 21, 2019 (support for hmacWithSHA256 was added in 302a4dee6c),
and trying to load such keys into nginx compiled with an old SSL library
results in "unsupported prf" errors.
To facilitate testing with old SSL libraries, keys are now generated
with "openssl genrsa -traditional" if the flag is available.
diffstat:
grpc_ssl.t | 3 ++-
mail_ssl.t | 3 ++-
proxy_ssl_certificate.t | 3 ++-
proxy_ssl_certificate_vars.t | 3 ++-
ssl_certificate.t | 3 ++-
ssl_password_file.t | 4 +++-
stream_proxy_ssl_certificate.t | 3 ++-
stream_proxy_ssl_certificate_vars.t | 3 ++-
stream_ssl.t | 4 +++-
stream_ssl_certificate.t | 3 ++-
uwsgi_ssl_certificate.t | 3 ++-
uwsgi_ssl_certificate_vars.t | 3 ++-
12 files changed, 26 insertions(+), 12 deletions(-)
diffs (232 lines):
diff --git a/grpc_ssl.t b/grpc_ssl.t
--- a/grpc_ssl.t
+++ b/grpc_ssl.t
@@ -103,6 +103,7 @@ distinguished_name = req_distinguished_n
EOF
my $d = $t->testdir();
+my $tr = `openssl genrsa -help 2>&1` =~ /-traditional/ ? '-traditional' : '';
foreach my $name ('localhost') {
system('openssl req -x509 -new '
@@ -114,7 +115,7 @@ foreach my $name ('localhost') {
foreach my $name ('client') {
system("openssl genrsa -out $d/$name.key -passout pass:$name "
- . "-aes128 2048 >>$d/openssl.out 2>&1") == 0
+ . "-aes128 $tr 2048 >>$d/openssl.out 2>&1") == 0
or die "Can't create private key: $!\n";
system('openssl req -x509 -new '
. "-config $d/openssl.conf -subj /CN=$name/ "
diff --git a/mail_ssl.t b/mail_ssl.t
--- a/mail_ssl.t
+++ b/mail_ssl.t
@@ -115,10 +115,11 @@ distinguished_name = req_distinguished_n
EOF
my $d = $t->testdir();
+my $tr = `openssl genrsa -help 2>&1` =~ /-traditional/ ? '-traditional' : '';
foreach my $name ('localhost', 'inherits') {
system("openssl genrsa -out $d/$name.key -passout pass:localhost "
- . "-aes128 2048 >>$d/openssl.out 2>&1") == 0
+ . "-aes128 $tr 2048 >>$d/openssl.out 2>&1") == 0
or die "Can't create private key: $!\n";
system('openssl req -x509 -new '
. "-config $d/openssl.conf -subj /CN=$name/ "
diff --git a/proxy_ssl_certificate.t b/proxy_ssl_certificate.t
--- a/proxy_ssl_certificate.t
+++ b/proxy_ssl_certificate.t
@@ -107,6 +107,7 @@ distinguished_name = req_distinguished_n
EOF
my $d = $t->testdir();
+my $tr = `openssl genrsa -help 2>&1` =~ /-traditional/ ? '-traditional' : '';
foreach my $name ('1.example.com', '2.example.com') {
system('openssl req -x509 -new '
@@ -118,7 +119,7 @@ foreach my $name ('1.example.com', '2.ex
foreach my $name ('3.example.com') {
system("openssl genrsa -out $d/$name.key -passout pass:$name "
- . "-aes128 2048 >>$d/openssl.out 2>&1") == 0
+ . "-aes128 $tr 2048 >>$d/openssl.out 2>&1") == 0
or die "Can't create private key: $!\n";
system('openssl req -x509 -new '
. "-config $d/openssl.conf -subj /CN=$name/ "
diff --git a/proxy_ssl_certificate_vars.t b/proxy_ssl_certificate_vars.t
--- a/proxy_ssl_certificate_vars.t
+++ b/proxy_ssl_certificate_vars.t
@@ -106,6 +106,7 @@ distinguished_name = req_distinguished_n
EOF
my $d = $t->testdir();
+my $tr = `openssl genrsa -help 2>&1` =~ /-traditional/ ? '-traditional' : '';
foreach my $name ('1.example.com', '2.example.com') {
system('openssl req -x509 -new '
@@ -117,7 +118,7 @@ foreach my $name ('1.example.com', '2.ex
foreach my $name ('3.example.com') {
system("openssl genrsa -out $d/$name.key -passout pass:$name "
- . "-aes128 2048 >>$d/openssl.out 2>&1") == 0
+ . "-aes128 $tr 2048 >>$d/openssl.out 2>&1") == 0
or die "Can't create private key: $!\n";
system('openssl req -x509 -new '
. "-config $d/openssl.conf -subj /CN=$name/ "
diff --git a/ssl_certificate.t b/ssl_certificate.t
--- a/ssl_certificate.t
+++ b/ssl_certificate.t
@@ -125,6 +125,7 @@ distinguished_name = req_distinguished_n
EOF
my $d = $t->testdir();
+my $tr = `openssl genrsa -help 2>&1` =~ /-traditional/ ? '-traditional' : '';
foreach my $name ('one', 'two') {
system('openssl req -x509 -new '
@@ -136,7 +137,7 @@ foreach my $name ('one', 'two') {
foreach my $name ('pass') {
system("openssl genrsa -out $d/$name.key -passout pass:pass "
- . "-aes128 2048 >>$d/openssl.out 2>&1") == 0
+ . "-aes128 $tr 2048 >>$d/openssl.out 2>&1") == 0
or die "Can't create $name key: $!\n";
system("openssl req -x509 -new -config $d/openssl.conf "
. "-subj /CN=$name/ -out $d/$name.crt -key $d/$name.key "
diff --git a/ssl_password_file.t b/ssl_password_file.t
--- a/ssl_password_file.t
+++ b/ssl_password_file.t
@@ -94,11 +94,13 @@ distinguished_name = req_distinguished_n
EOF
my $d = $t->testdir();
+my $tr = `openssl genrsa -help 2>&1` =~ /-traditional/ ? '-traditional' : '';
+
mkfifo("$d/password_fifo", 0700);
foreach my $name ('localhost', 'inherits') {
system("openssl genrsa -out $d/$name.key -passout pass:$name "
- . "-aes128 2048 >>$d/openssl.out 2>&1") == 0
+ . "-aes128 $tr 2048 >>$d/openssl.out 2>&1") == 0
or die "Can't create private key: $!\n";
system('openssl req -x509 -new '
. "-config $d/openssl.conf -subj /CN=$name/ "
diff --git a/stream_proxy_ssl_certificate.t b/stream_proxy_ssl_certificate.t
--- a/stream_proxy_ssl_certificate.t
+++ b/stream_proxy_ssl_certificate.t
@@ -113,6 +113,7 @@ distinguished_name = req_distinguished_n
EOF
my $d = $t->testdir();
+my $tr = `openssl genrsa -help 2>&1` =~ /-traditional/ ? '-traditional' : '';
foreach my $name ('1.example.com', '2.example.com') {
system('openssl req -x509 -new '
@@ -124,7 +125,7 @@ foreach my $name ('1.example.com', '2.ex
foreach my $name ('3.example.com') {
system("openssl genrsa -out $d/$name.key -passout pass:$name "
- . "-aes128 2048 >>$d/openssl.out 2>&1") == 0
+ . "-aes128 $tr 2048 >>$d/openssl.out 2>&1") == 0
or die "Can't create private key: $!\n";
system('openssl req -x509 -new '
. "-config $d/openssl.conf -subj /CN=$name/ "
diff --git a/stream_proxy_ssl_certificate_vars.t b/stream_proxy_ssl_certificate_vars.t
--- a/stream_proxy_ssl_certificate_vars.t
+++ b/stream_proxy_ssl_certificate_vars.t
@@ -120,6 +120,7 @@ distinguished_name = req_distinguished_n
EOF
my $d = $t->testdir();
+my $tr = `openssl genrsa -help 2>&1` =~ /-traditional/ ? '-traditional' : '';
foreach my $name ('1.example.com', '2.example.com') {
system('openssl req -x509 -new '
@@ -131,7 +132,7 @@ foreach my $name ('1.example.com', '2.ex
foreach my $name ('3.example.com') {
system("openssl genrsa -out $d/$name.key -passout pass:$name "
- . "-aes128 2048 >>$d/openssl.out 2>&1") == 0
+ . "-aes128 $tr 2048 >>$d/openssl.out 2>&1") == 0
or die "Can't create private key: $!\n";
system('openssl req -x509 -new '
. "-config $d/openssl.conf -subj /CN=$name/ "
diff --git a/stream_ssl.t b/stream_ssl.t
--- a/stream_ssl.t
+++ b/stream_ssl.t
@@ -90,11 +90,13 @@ distinguished_name = req_distinguished_n
EOF
my $d = $t->testdir();
+my $tr = `openssl genrsa -help 2>&1` =~ /-traditional/ ? '-traditional' : '';
+
mkfifo("$d/password_fifo", 0700);
foreach my $name ('localhost', 'inherits') {
system("openssl genrsa -out $d/$name.key -passout pass:$name "
- . "-aes128 2048 >>$d/openssl.out 2>&1") == 0
+ . "-aes128 $tr 2048 >>$d/openssl.out 2>&1") == 0
or die "Can't create private key: $!\n";
system('openssl req -x509 -new '
. "-config $d/openssl.conf -subj /CN=$name/ "
diff --git a/stream_ssl_certificate.t b/stream_ssl_certificate.t
--- a/stream_ssl_certificate.t
+++ b/stream_ssl_certificate.t
@@ -108,6 +108,7 @@ distinguished_name = req_distinguished_n
EOF
my $d = $t->testdir();
+my $tr = `openssl genrsa -help 2>&1` =~ /-traditional/ ? '-traditional' : '';
foreach my $name ('one', 'two') {
system('openssl req -x509 -new '
@@ -119,7 +120,7 @@ foreach my $name ('one', 'two') {
foreach my $name ('pass') {
system("openssl genrsa -out $d/$name.key -passout pass:pass "
- . "-aes128 2048 >>$d/openssl.out 2>&1") == 0
+ . "-aes128 $tr 2048 >>$d/openssl.out 2>&1") == 0
or die "Can't create $name key: $!\n";
system("openssl req -x509 -new -config $d/openssl.conf "
. "-subj /CN=$name/ -out $d/$name.crt -key $d/$name.key "
diff --git a/uwsgi_ssl_certificate.t b/uwsgi_ssl_certificate.t
--- a/uwsgi_ssl_certificate.t
+++ b/uwsgi_ssl_certificate.t
@@ -105,6 +105,7 @@ distinguished_name = req_distinguished_n
EOF
my $d = $t->testdir();
+my $tr = `openssl genrsa -help 2>&1` =~ /-traditional/ ? '-traditional' : '';
foreach my $name ('1.example.com', '2.example.com') {
system('openssl req -x509 -new '
@@ -116,7 +117,7 @@ foreach my $name ('1.example.com', '2.ex
foreach my $name ('3.example.com') {
system("openssl genrsa -out $d/$name.key -passout pass:$name "
- . "-aes128 2048 >>$d/openssl.out 2>&1") == 0
+ . "-aes128 $tr 2048 >>$d/openssl.out 2>&1") == 0
or die "Can't create private key: $!\n";
system('openssl req -x509 -new '
. "-config $d/openssl.conf -subj /CN=$name/ "
diff --git a/uwsgi_ssl_certificate_vars.t b/uwsgi_ssl_certificate_vars.t
--- a/uwsgi_ssl_certificate_vars.t
+++ b/uwsgi_ssl_certificate_vars.t
@@ -104,6 +104,7 @@ distinguished_name = req_distinguished_n
EOF
my $d = $t->testdir();
+my $tr = `openssl genrsa -help 2>&1` =~ /-traditional/ ? '-traditional' : '';
foreach my $name ('1.example.com', '2.example.com') {
system('openssl req -x509 -new '
@@ -115,7 +116,7 @@ foreach my $name ('1.example.com', '2.ex
foreach my $name ('3.example.com') {
system("openssl genrsa -out $d/$name.key -passout pass:$name "
- . "-aes128 2048 >>$d/openssl.out 2>&1") == 0
+ . "-aes128 $tr 2048 >>$d/openssl.out 2>&1") == 0
or die "Can't create private key: $!\n";
system('openssl req -x509 -new '
. "-config $d/openssl.conf -subj /CN=$name/ "
More information about the nginx-devel
mailing list