summaryrefslogtreecommitdiffstats
path: root/catalog-be/src/main/docker/backend/chef-repo
diff options
context:
space:
mode:
authorMichaelMorris <michael.morris@est.tech>2023-09-20 09:23:28 +0100
committerVasyl Razinkov <vasyl.razinkov@est.tech>2023-10-17 15:44:57 +0000
commit980530fa79f437332ec9b83f728c47b42d162ac2 (patch)
treee86dc82a69d45b2222a7c92b76c7e3d944925719 /catalog-be/src/main/docker/backend/chef-repo
parent21f652a75ecd4d1e16204fb78e638885197293d1 (diff)
sdc-be certificate handling
Signed-off-by: MichaelMorris <michael.morris@est.tech> Issue-ID: SDC-4639 Change-Id: I257bd74e7a969b8c7d686952dd46425e969ddb24
Diffstat (limited to 'catalog-be/src/main/docker/backend/chef-repo')
-rw-r--r--catalog-be/src/main/docker/backend/chef-repo/cookbooks/sdc-catalog-be/recipes/BE_3_setup_key_and_trust_store.rb21
1 files changed, 21 insertions, 0 deletions
diff --git a/catalog-be/src/main/docker/backend/chef-repo/cookbooks/sdc-catalog-be/recipes/BE_3_setup_key_and_trust_store.rb b/catalog-be/src/main/docker/backend/chef-repo/cookbooks/sdc-catalog-be/recipes/BE_3_setup_key_and_trust_store.rb
new file mode 100644
index 0000000000..66562d8ba9
--- /dev/null
+++ b/catalog-be/src/main/docker/backend/chef-repo/cookbooks/sdc-catalog-be/recipes/BE_3_setup_key_and_trust_store.rb
@@ -0,0 +1,21 @@
+#Set the http module option
+if node['BE'][:tls_cert]
+ execute "generate-keystore" do
+ command "openssl pkcs12 -inkey #{node['BE'][:tls_key]} -in #{node['BE'][:tls_cert]} -export -out /tmp/keystore.pkcs12 -passin pass:#{node['BE'][:tls_password]} -passout pass:#{node['BE'][:tls_password]}"
+ end
+
+ execute "import-keystore" do
+ command "keytool -importkeystore -srcstoretype PKCS12 -srckeystore /tmp/keystore.pkcs12 -srcstorepass #{node['BE'][:tls_password]} -destkeystore #{ENV['JETTY_BASE']}/#{node['BE'][:keystore_path]} -deststorepass #{node['BE'][:keystore_password]} -noprompt"
+ end
+end
+
+if node['BE'][:ca_cert]
+ execute "delete-existing-ca-alias" do
+ command "keytool -delete -alias sdc-be -storepass #{node['BE'][:truststore_password]} -keystore #{ENV['JETTY_BASE']}/#{node['BE'][:truststore_path]}"
+ returns [0, 1]
+ end
+
+ execute "generate-truststore" do
+ command "keytool -import -alias sdc-be -file #{node['BE'][:ca_cert]} -storetype JKS -keystore #{ENV['JETTY_BASE']}/#{node['BE'][:truststore_path]} -storepass #{node['BE'][:truststore_password]} -noprompt"
+ end
+end