Skip to content

Instantly share code, notes, and snippets.

@ro31337
Last active October 31, 2022 18:04
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save ro31337/237f982080a859ef9a44 to your computer and use it in GitHub Desktop.
Save ro31337/237f982080a859ef9a44 to your computer and use it in GitHub Desktop.
Install ssl certificates for winfows (to avoid error on Windows OpenSSL::SSL::SSLError: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed). Make sure you added SSL_CERT_FILE environment variable!
require 'net/http'
ruby_install_dir = 'c:\Ruby200-x64'
cacert_file = "#{ruby_install_dir}\\cacert.pem"
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"
puts "* Please set SSL_CERT_FILE in your current command prompt session with:"
puts " set 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."
end
end
@forgemest
Copy link

В 2022 - это актуально?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment