summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorPete Higgins <pete@peterhiggins.org>2020-12-16 14:39:37 -0800
committerPete Higgins <pete@peterhiggins.org>2020-12-16 14:39:37 -0800
commit8f2cbbdc7fb504cbf19b38321995870af32ef0b0 (patch)
tree8e8fd1650438f2d02d0f1f8f2cac9480648833e0 /spec
parent34610f3efad8c8424760014a7ade4c721d3e12c7 (diff)
downloadchef-8f2cbbdc7fb504cbf19b38321995870af32ef0b0.tar.gz
Properly handle DER encoded certs and keys.
Signed-off-by: Pete Higgins <pete@peterhiggins.org>
Diffstat (limited to 'spec')
-rw-r--r--spec/data/ssl/chef-rspec-der.certbin0 -> 1174 bytes
-rw-r--r--spec/data/ssl/chef-rspec-der.keybin0 -> 1191 bytes
-rw-r--r--spec/data/trusted_certs/example_der.crtbin0 -> 1174 bytes
-rw-r--r--spec/unit/http/ssl_policies_spec.rb14
4 files changed, 14 insertions, 0 deletions
diff --git a/spec/data/ssl/chef-rspec-der.cert b/spec/data/ssl/chef-rspec-der.cert
new file mode 100644
index 0000000000..e49df6252a
--- /dev/null
+++ b/spec/data/ssl/chef-rspec-der.cert
Binary files differ
diff --git a/spec/data/ssl/chef-rspec-der.key b/spec/data/ssl/chef-rspec-der.key
new file mode 100644
index 0000000000..d8adadc5c9
--- /dev/null
+++ b/spec/data/ssl/chef-rspec-der.key
Binary files differ
diff --git a/spec/data/trusted_certs/example_der.crt b/spec/data/trusted_certs/example_der.crt
new file mode 100644
index 0000000000..e49df6252a
--- /dev/null
+++ b/spec/data/trusted_certs/example_der.crt
Binary files differ
diff --git a/spec/unit/http/ssl_policies_spec.rb b/spec/unit/http/ssl_policies_spec.rb
index 614b5018d1..245f66bf0d 100644
--- a/spec/unit/http/ssl_policies_spec.rb
+++ b/spec/unit/http/ssl_policies_spec.rb
@@ -122,6 +122,20 @@ describe "HTTP SSL Policy" do
expect(http_client.cert.to_s).to eq(OpenSSL::X509::Certificate.new(IO.read(CHEF_SPEC_DATA + "/ssl/chef-rspec.cert")).to_s)
expect(http_client.key.to_s).to eq(OpenSSL::PKey::RSA.new(IO.read(CHEF_SPEC_DATA + "/ssl/chef-rspec.key")).to_s)
end
+
+ it "configures the HTTP client's cert and private key with a DER encoded cert" do
+ Chef::Config[:ssl_client_cert] = CHEF_SPEC_DATA + "/ssl/chef-rspec-der.cert"
+ Chef::Config[:ssl_client_key] = CHEF_SPEC_DATA + "/ssl/chef-rspec.key"
+ expect(http_client.cert.to_s).to eq(OpenSSL::X509::Certificate.new(IO.read(CHEF_SPEC_DATA + "/ssl/chef-rspec.cert")).to_s)
+ expect(http_client.key.to_s).to eq(OpenSSL::PKey::RSA.new(IO.read(CHEF_SPEC_DATA + "/ssl/chef-rspec.key")).to_s)
+ end
+
+ it "configures the HTTP client's cert and private key with a DER encoded key" do
+ Chef::Config[:ssl_client_cert] = CHEF_SPEC_DATA + "/ssl/chef-rspec.cert"
+ Chef::Config[:ssl_client_key] = CHEF_SPEC_DATA + "/ssl/chef-rspec-der.key"
+ expect(http_client.cert.to_s).to eq(OpenSSL::X509::Certificate.new(IO.read(CHEF_SPEC_DATA + "/ssl/chef-rspec.cert")).to_s)
+ expect(http_client.key.to_s).to eq(OpenSSL::PKey::RSA.new(IO.read(CHEF_SPEC_DATA + "/ssl/chef-rspec.key")).to_s)
+ end
end
context "when additional certs are located in the trusted_certs dir" do