Mercurial > hg > nginx-tests
comparison stream_ssl_certificate.t @ 1974:b5036a0f9ae0 default tip
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.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Mon, 06 May 2024 00:04:26 +0300 |
parents | c924ae8d7104 |
children |
comparison
equal
deleted
inserted
replaced
1973:94e0390dc64f | 1974:b5036a0f9ae0 |
---|---|
106 distinguished_name = req_distinguished_name | 106 distinguished_name = req_distinguished_name |
107 [ req_distinguished_name ] | 107 [ req_distinguished_name ] |
108 EOF | 108 EOF |
109 | 109 |
110 my $d = $t->testdir(); | 110 my $d = $t->testdir(); |
111 my $tr = `openssl genrsa -help 2>&1` =~ /-traditional/ ? '-traditional' : ''; | |
111 | 112 |
112 foreach my $name ('one', 'two') { | 113 foreach my $name ('one', 'two') { |
113 system('openssl req -x509 -new ' | 114 system('openssl req -x509 -new ' |
114 . "-config $d/openssl.conf -subj /CN=$name/ " | 115 . "-config $d/openssl.conf -subj /CN=$name/ " |
115 . "-out $d/$name.crt -keyout $d/$name.key " | 116 . "-out $d/$name.crt -keyout $d/$name.key " |
117 or die "Can't create certificate for $name: $!\n"; | 118 or die "Can't create certificate for $name: $!\n"; |
118 } | 119 } |
119 | 120 |
120 foreach my $name ('pass') { | 121 foreach my $name ('pass') { |
121 system("openssl genrsa -out $d/$name.key -passout pass:pass " | 122 system("openssl genrsa -out $d/$name.key -passout pass:pass " |
122 . "-aes128 2048 >>$d/openssl.out 2>&1") == 0 | 123 . "-aes128 $tr 2048 >>$d/openssl.out 2>&1") == 0 |
123 or die "Can't create $name key: $!\n"; | 124 or die "Can't create $name key: $!\n"; |
124 system("openssl req -x509 -new -config $d/openssl.conf " | 125 system("openssl req -x509 -new -config $d/openssl.conf " |
125 . "-subj /CN=$name/ -out $d/$name.crt -key $d/$name.key " | 126 . "-subj /CN=$name/ -out $d/$name.crt -key $d/$name.key " |
126 . "-passin pass:pass >>$d/openssl.out 2>&1") == 0 | 127 . "-passin pass:pass >>$d/openssl.out 2>&1") == 0 |
127 or die "Can't create $name certificate: $!\n"; | 128 or die "Can't create $name certificate: $!\n"; |