Skip to content

Instantly share code, notes, and snippets.

@ecounysis
Created April 1, 2016 21:05
Show Gist options
  • Save ecounysis/187819e3c7c6ec425249666b58fca4b8 to your computer and use it in GitHub Desktop.
Save ecounysis/187819e3c7c6ec425249666b58fca4b8 to your computer and use it in GitHub Desktop.
require 'net/https'
require 'uri'
# create a path to the file "C:\RailsInstaller\cacert.pem"
cacert_file = File.join(%w{c: RailsInstaller cacert.pem})
uri = URI.parse("https://curl.haxx.se/ca/cacert.pem")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Get.new(uri.request_uri)
response = http.request(request)
if response.code == "200"
open(cacert_file, "wb") { |file| file.write(response.body) }
puts "\n\nA bundle of certificate authorities has been installed to"
puts "C:\\RailsInstaller\\cacert.pem\n"
puts "* Please set SSL_CERT_FILE in your current command prompt session with:"
puts " set SSL_CERT_FILE=C:\\RailsInstaller\\cacert.pem"
puts "* To make this a permanent setting, add it to Environment Variables"
puts " under Control Panel -> Advanced -> Environment Variables"
else
abort "\n\n>>>> A cacert.pem bundle could not be downloaded."
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment