From 4a52e18c6c2dab0d1e33d18cd3dff077773a0e41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20=C5=98eho=C5=99?= Date: Thu, 3 Aug 2017 23:48:56 +0200 Subject: [PATCH] Add support for PKCS#8 format to X509PrivateKey#encrypted? X509PrivateKey#encrypted? supports only old format of RSA encrypted private key. This PR adds support for PKCS#8 format (see RFC7468). --- lib/serverspec/type/x509_private_key.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/serverspec/type/x509_private_key.rb b/lib/serverspec/type/x509_private_key.rb index 1bb95686..87873c99 100644 --- a/lib/serverspec/type/x509_private_key.rb +++ b/lib/serverspec/type/x509_private_key.rb @@ -8,7 +8,7 @@ def valid? end def encrypted? - @runner.run_command("grep -wq \"^Proc-Type.*ENCRYPTED$\" #{name}").exit_status == 0 + @runner.run_command("grep -Ewq \"^(Proc-Type.*ENCRYPTED|-----BEGIN ENCRYPTED PRIVATE KEY-----)$\" #{name}").exit_status == 0 end def has_matching_certificate?(cert_file)