Created
April 5, 2017 19:12
-
-
Save dayne/d029606d7a917fd29e6e475e70278646 to your computer and use it in GitHub Desktop.
grab ca certs for use on windows box.. sigh
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
$ cat ../win_fetch_cacerts.rb | |
require 'net/http' | |
require 'openssl' | |
require 'fileutils' | |
cert_dir = '/C/Ruby23-x64/lib/ruby/site_ruby/2.3.0/rubygems/ssl_certs/curl.haxx.se' | |
FileUtils.mkdir cert_dir unless File.directory?(cert_dir) | |
# create a path to the file "C:\RailsInstaller\cacert.pem" | |
cacert_file = File.join(cert_dir, 'cacert.pem') | |
uri = URI.parse("https://curl.haxx.se") | |
http = Net::HTTP.new(uri.host, uri.port) | |
http.use_ssl = true | |
http.verify_mode = OpenSSL::SSL::VERIFY_NONE | |
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 cert_dir | |
puts "* Please set SSL_CERT_FILE in your current command prompt session with:" | |
puts " export SSL_CERT_FILE="+cacert_file | |
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." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment