# HG changeset patch # User Maxim Dounin # Date 1637629087 -10800 # Node ID 7f09d144d15c8bd8416b6d1aebeda27e928dd56e # Parent be8d5213d6b9f07a3a8090c8dd48b4beab4d883f Tests: updated ssl_engine_keys.t test to use SoftHSM v2. Notably, this implies not using slots to identify keys, since "softhsm2-util --init-token" automatically reassigns initialized token to a new slot. Additionally, the "-config" option of is no longer used when generating certificates, as in OpenSSL 1.1.0 and later it conflicts with the configuration file provided via OPENSSL_CONF and results in "conflicting engine id" errors. diff --git a/ssl_engine_keys.t b/ssl_engine_keys.t --- a/ssl_engine_keys.t +++ b/ssl_engine_keys.t @@ -28,7 +28,7 @@ plan(skip_all => 'may not work, leaves c unless $ENV{TEST_NGINX_UNSAFE}; my $t = Test::Nginx->new()->has(qw/http proxy http_ssl/)->has_daemon('openssl') - ->has_daemon('softhsm')->has_daemon('pkcs11-tool')->plan(2); + ->has_daemon('softhsm2-util')->has_daemon('pkcs11-tool')->plan(2); $t->write_file_expand('nginx.conf', <<'EOF'); @@ -48,7 +48,7 @@ http { server_name localhost; ssl_certificate localhost.crt; - ssl_certificate_key engine:pkcs11:slot_0-id_00; + ssl_certificate_key engine:pkcs11:id_00; location / { # index index.html by default @@ -70,7 +70,7 @@ http { server_name localhost; ssl_certificate $ssl_server_name.crt; - ssl_certificate_key engine:pkcs11:slot_0-id_00; + ssl_certificate_key engine:pkcs11:id_00; location / { # index index.html by default @@ -101,7 +101,7 @@ pkcs11 = pkcs11_section [pkcs11_section] engine_id = pkcs11 dynamic_path = /usr/local/lib/engines/pkcs11.so -MODULE_PATH = /usr/local/lib/softhsm/libsofthsm.so +MODULE_PATH = /usr/local/lib/softhsm/libsofthsm2.so init = 1 PIN = 1234 @@ -114,25 +114,28 @@ EOF my $d = $t->testdir(); -$t->write_file('softhsm.conf', <write_file('softhsm2.conf', <>$d/openssl.out 2>&1"); - system('pkcs11-tool --module=/usr/local/lib/softhsm/libsofthsm.so ' + system('pkcs11-tool --module=/usr/local/lib/softhsm/libsofthsm2.so ' . '-p 1234 -l -k -d 0 -a nx_key_0 --key-type rsa:2048 ' . ">>$d/openssl.out 2>&1"); - system('openssl req -x509 -new -engine pkcs11 ' - . "-config $d/openssl.conf -subj /CN=$name/ " - . "-out $d/$name.crt -keyform engine -text -key id_00 " + system('openssl req -x509 -new ' + . "-subj /CN=$name/ -out $d/$name.crt -text " + . "-engine pkcs11 -keyform engine -key id_00 " . ">>$d/openssl.out 2>&1") == 0 or die "Can't create certificate for $name: $!\n"; }