Skip to content

Instantly share code, notes, and snippets.

@scottsbaldwin
Forked from lusis/keytool.rb
Created May 23, 2012 20:29
Show Gist options
  • Save scottsbaldwin/2777602 to your computer and use it in GitHub Desktop.
Save scottsbaldwin/2777602 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