Created
February 5, 2016 09:27
-
-
Save otakusid/73ddd3072b3efb491234 to your computer and use it in GitHub Desktop.
Download latest SSL certificate and setup environment to make it accessible for Ruby
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
task :configure_ssl do | |
puts 'configure SSL' | |
cacert_file = File.join(Dir.tmpdir, 'cacert.pem') | |
if File.exist?(cacert_file) | |
puts "Used #{cacert_file} bundle of certificate authorities" | |
else | |
Net::HTTP.start("curl.haxx.se") do |http| | |
resp = http.get("/ca/cacert.pem") | |
if resp.code == "200" | |
open(cacert_file, "wb") { |file| file.write(resp.body) } | |
puts "\n\nA bundle of certificate authorities has been installed to" | |
puts "#{cacert_file}\n" | |
else | |
abort "\n\n>>>> A cacert.pem bundle could not be downloaded." | |
end | |
end | |
end | |
ENV['SSL_CERT_FILE'] = cacert_file | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment