Skip to content

Instantly share code, notes, and snippets.

@snipsnipsnip
Last active March 1, 2016 13:39
Show Gist options
  • Save snipsnipsnip/5a9abe5b72fdbe32f0df to your computer and use it in GitHub Desktop.
Save snipsnipsnip/5a9abe5b72fdbe32f0df to your computer and use it in GitHub Desktop.
prepare-cacert-pem.rb
require 'fileutils'
require 'openssl'
require 'open-uri'
CACERT_URI = 'https://curl.haxx.se/ca/cacert.pem'
def main
if force = ARGV.include?('-f') || ARGV.include?('--force')
u = FileUtils::Verbose
else
u = FileUtils::DryRun
end
p u
path = OpenSSL::X509::DEFAULT_CERT_FILE
u.mkdir_p File.dirname(path)
puts "GET #{CACERT_URI} > #{path}"
IO.binwrite(path, mozilla_certs) if force
end
def mozilla_certs
URI(CACERT_URI).read(:ssl_verify_mode => OpenSSL::SSL::VERIFY_NONE)
end
main if $0 == __FILE__
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment