Last active
March 1, 2016 13:39
-
-
Save snipsnipsnip/5a9abe5b72fdbe32f0df to your computer and use it in GitHub Desktop.
prepare-cacert-pem.rb
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
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