Skip to content

Commit 58e9cae

Browse files
toddr-botclaude
andcommitted
Skip unencrypted PKCS#8 DER import test on pre-3.x
On pre-3.x, new_private_key() without a passphrase calls d2i_RSAPrivateKey_bio() which only handles PKCS#1 DER format. Unencrypted PKCS#8 DER import is not supported until OpenSSL 3.x (or with the fix in PR cpan-authors#190). Without this skip, the test dies on Debian bullseye (OpenSSL 1.1.1), killing the remaining 6 tests. The encrypted PKCS#8 DER tests still run on pre-3.x because the passphrase code path uses d2i_PKCS8PrivateKey_bio() which handles PKCS#8 correctly. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 638686c commit 58e9cae

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

t/der.t

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@ use warnings;
33
use Test::More;
44
use MIME::Base64;
55
use Crypt::OpenSSL::RSA;
6+
use Crypt::OpenSSL::Guess qw(openssl_version);
67

78
use File::Temp qw(tempfile);
89

10+
my ($major, $minor, $patch) = openssl_version();
11+
912
BEGIN { plan tests => 49 }
1013

1114
# --- Generate a key pair for testing ---
@@ -234,9 +237,13 @@ is( ord(substr($pkcs8_der_export, 0, 1)), 0x30,
234237
is( $pkcs8_der_export, $pkcs8_der_expected,
235238
"get_private_key_pkcs8_der_string matches pem_to_der of PEM export" );
236239

237-
my $priv_from_pkcs8_der_export = Crypt::OpenSSL::RSA->new_private_key($pkcs8_der_export);
238-
ok( $priv_from_pkcs8_der_export->is_private(),
239-
"PKCS#8 DER export round-trips as private key" );
240+
SKIP: {
241+
skip "Unencrypted PKCS#8 DER import requires OpenSSL 3.x", 1
242+
if $major < 3 || !defined $patch;
243+
my $priv_from_pkcs8_der_export = Crypt::OpenSSL::RSA->new_private_key($pkcs8_der_export);
244+
ok( $priv_from_pkcs8_der_export->is_private(),
245+
"PKCS#8 DER export round-trips as private key" );
246+
}
240247

241248
# Encrypted PKCS#8 DER export
242249
my $der_pass = 'test_export_pass';

0 commit comments

Comments
 (0)