summaryrefslogtreecommitdiff
path: root/kitchen-tests
diff options
context:
space:
mode:
authorTim Smith <tsmith84@gmail.com>2020-08-19 12:56:35 -0700
committerTim Smith <tsmith84@gmail.com>2020-08-19 13:39:02 -0700
commit78ccdeaff047c1c8537a3dd686ba1f777858c1c5 (patch)
tree022589771d08844b1e0b3c7dffb82d18eccd152a /kitchen-tests
parent0f3f63d6f427368eb2d0193c4e363d8a6f7d6f9a (diff)
downloadchef-78ccdeaff047c1c8537a3dd686ba1f777858c1c5.tar.gz
Add new chef_client_trusted_certificate resource
This is a pretty simple resource for something that users can certainly do on their own right now, but most people don't even realize is an option. Giving it a dedicated resource exposes the functionality better and just makes it that much easier to write a simple cross platform cookbook that involves configuring the client. I'm not a huge fan of having to provide the certificate as a string, but I didn't want to add yet another place where we allow string values, or URI. They all have slightly different APIs and we need to just do it via a mixin or something. This can certainly move that direction in the future, but for this solves a real problem today. Signed-off-by: Tim Smith <tsmith@chef.io>
Diffstat (limited to 'kitchen-tests')
-rw-r--r--kitchen-tests/cookbooks/end_to_end/recipes/_chef_client_trusted_certificate.rb30
-rw-r--r--kitchen-tests/cookbooks/end_to_end/recipes/linux.rb1
-rw-r--r--kitchen-tests/cookbooks/end_to_end/recipes/macos.rb1
-rw-r--r--kitchen-tests/cookbooks/end_to_end/recipes/windows.rb1
4 files changed, 33 insertions, 0 deletions
diff --git a/kitchen-tests/cookbooks/end_to_end/recipes/_chef_client_trusted_certificate.rb b/kitchen-tests/cookbooks/end_to_end/recipes/_chef_client_trusted_certificate.rb
new file mode 100644
index 0000000000..486d5f36c6
--- /dev/null
+++ b/kitchen-tests/cookbooks/end_to_end/recipes/_chef_client_trusted_certificate.rb
@@ -0,0 +1,30 @@
+chef_client_trusted_certificate "self-signed.badssl.com" do
+ certificate <<~CERT
+ -----BEGIN CERTIFICATE-----
+ MIIDeTCCAmGgAwIBAgIJAPziuikCTox4MA0GCSqGSIb3DQEBCwUAMGIxCzAJBgNV
+ BAYTAlVTMRMwEQYDVQ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NvCZb2CkjZWmxkGPuoP40/y7Yu5OFqxP5tAjj4YixCYTW
+ EVA0pmzIzgBg+JIe3PdRy27T0asgQW/F4TY61Yk=
+ -----END CERTIFICATE-----
+ CERT
+end
+
+# see if we can fetch from our new trusted domain
+remote_file ::File.join(Chef::Config[:file_cache_path], "index.html") do
+ source "https://self-signed.badssl.com/index.html"
+end \ No newline at end of file
diff --git a/kitchen-tests/cookbooks/end_to_end/recipes/linux.rb b/kitchen-tests/cookbooks/end_to_end/recipes/linux.rb
index 012a9a7507..8fae36662c 100644
--- a/kitchen-tests/cookbooks/end_to_end/recipes/linux.rb
+++ b/kitchen-tests/cookbooks/end_to_end/recipes/linux.rb
@@ -50,6 +50,7 @@ ssh_known_hosts_entry "github.com"
include_recipe "chef-client::delete_validation"
include_recipe "chef-client::config"
+include_recipe "::_chef_client_trusted_certificate"
include_recipe "openssh"
diff --git a/kitchen-tests/cookbooks/end_to_end/recipes/macos.rb b/kitchen-tests/cookbooks/end_to_end/recipes/macos.rb
index 6ac2607caa..9c7416cfd9 100644
--- a/kitchen-tests/cookbooks/end_to_end/recipes/macos.rb
+++ b/kitchen-tests/cookbooks/end_to_end/recipes/macos.rb
@@ -41,6 +41,7 @@ ssh_known_hosts_entry "github.com"
include_recipe "chef-client::delete_validation"
include_recipe "chef-client::config"
+include_recipe "::_chef_client_trusted_certificate"
include_recipe "git"
diff --git a/kitchen-tests/cookbooks/end_to_end/recipes/windows.rb b/kitchen-tests/cookbooks/end_to_end/recipes/windows.rb
index aa53ca6365..3e069a43b0 100644
--- a/kitchen-tests/cookbooks/end_to_end/recipes/windows.rb
+++ b/kitchen-tests/cookbooks/end_to_end/recipes/windows.rb
@@ -47,6 +47,7 @@ end
include_recipe "chef-client::delete_validation"
include_recipe "chef-client::config"
+include_recipe "::_chef_client_trusted_certificate"
include_recipe "git"