-
-
Save valadan/9ccc42b04752312a780005357ff46fc5 to your computer and use it in GitHub Desktop.
recipe for adding certs to keytool
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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