summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2018-12-19 20:08:02 -0800
committerGitHub <noreply@github.com>2018-12-19 20:08:02 -0800
commite2f8515f9600875be24e7ff6f7add5a353a60894 (patch)
tree3222c02c2df74eac294e41548ce09d4143cbbfba
parentdcad12ec1c24c759ea9d58cb926d43d6dde97d64 (diff)
parenta79aae4e168d765c4e8971a4fc037ef735f14676 (diff)
downloadchef-e2f8515f9600875be24e7ff6f7add5a353a60894.tar.gz
Merge pull request #8071 from chef/pfx_cert_14
chef 14: windows_certificate: Fix invalid byte sequence errors with pfx certicates
-rw-r--r--lib/chef/resource/windows_certificate.rb2
-rw-r--r--spec/unit/resource/windows_certificate.rb7
2 files changed, 8 insertions, 1 deletions
diff --git a/lib/chef/resource/windows_certificate.rb b/lib/chef/resource/windows_certificate.rb
index 20613a76bd..cf0b46dd6b 100644
--- a/lib/chef/resource/windows_certificate.rb
+++ b/lib/chef/resource/windows_certificate.rb
@@ -253,7 +253,7 @@ class Chef
when ".cer"
powershell_out("openssl x509 -text -inform DER -in #{source} -outform PEM").stdout
when ".pfx"
- powershell_out("openssl pkcs12 -in #{source} -nodes -passin pass:#{new_resource.pfx_password}").stdout
+ powershell_out("openssl pkcs12 -in #{source} -nodes -passin pass:'#{new_resource.pfx_password}'").stdout
when ".p7b"
powershell_out("openssl pkcs7 -print_certs -in #{source} -outform PEM").stdout
end
diff --git a/spec/unit/resource/windows_certificate.rb b/spec/unit/resource/windows_certificate.rb
index 97e404a2d5..95d465e4a8 100644
--- a/spec/unit/resource/windows_certificate.rb
+++ b/spec/unit/resource/windows_certificate.rb
@@ -73,4 +73,11 @@ describe Chef::Resource::WindowsCertificate do
resource.pfx_password "foo"
expect(resource.sensitive).to be_truthy
end
+
+ it "doesn't raise error if pfx_password contains special characters" do
+ resource.pfx_password "chef$123"
+ resource.source "C:\\certs\\test-cert.pfx"
+ resource.store_name "MY"
+ expect { resource.action :create }.not_to raise_error
+ end
end