Skip to content

Instantly share code, notes, and snippets.

@valadan
Forked from lusis/keytool.rb
Created January 31, 2017 03:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save valadan/9ccc42b04752312a780005357ff46fc5 to your computer and use it in GitHub Desktop.
Save valadan/9ccc42b04752312a780005357ff46fc5 to your computer and use it in GitHub Desktop.
recipe for adding certs to keytool
keystore = "/etc/java-6-sun/security/cacerts"
keystore_pass = "foobar"
# you'll need foo.cert et. al. in files/default
certs = %w{foo bar bang}
certs.each do |cert|
cookbook_file "#{Chef::Config[:file_cache_path]}/#{cert}.cert" do
source "#{cert}.cert"
end
execute "import #{cert} cert" do
command "keytool -import -trustcacerts -alias #{cert} -file #{Chef::Config[:file_cache_path]}/#{cert}.cert -keystore #{keystore} -storepass #{keystore_pass} -noprompt"
only_if { File.exists?("#{keystore}") }
not_if "keytool -list -keystore #{keystore} -storepass #{keystore_pass} -alias #{cert}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment