Skip to content

Instantly share code, notes, and snippets.

@lusis
Created March 26, 2012 04:51
Show Gist options
  • Save lusis/2203083 to your computer and use it in GitHub Desktop.
Save lusis/2203083 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