Skip to content

Instantly share code, notes, and snippets.

@otakusid
Created February 5, 2016 09:27
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 otakusid/73ddd3072b3efb491234 to your computer and use it in GitHub Desktop.
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
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