Skip to content

Commit

Permalink
Use cacert.pem for HTTPS connections
Browse files Browse the repository at this point in the history
If not exist, do not verify cert at all
  • Loading branch information
voxik authored and luislavena committed Dec 9, 2010
1 parent afa451d commit 0d02ff8
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
6 changes: 6 additions & 0 deletions config/ruby_installer.rb
Expand Up @@ -9,6 +9,12 @@ module RubyInstaller
SEVEN_ZIP = File.expand_path(File.join(ROOT, 'sandbox', 'extract_utils', '7za.exe'))
BSD_TAR = File.expand_path(File.join(ROOT, 'sandbox', 'extract_utils', 'basic-bsdtar.exe'))

# SSL Certificates
Certificate = OpenStruct.new(
:url => 'http://curl.haxx.se/ca',
:file => 'cacert.pem'
)

# MinGW files
MinGW = OpenStruct.new(
:release => 'current',
Expand Down
7 changes: 6 additions & 1 deletion rake/contrib/uri_ext.rb
Expand Up @@ -285,8 +285,13 @@ def connect
http = Net::HTTP.new(host, port)
end
if self.instance_of? URI::HTTPS
cacert = "downloads/#{RubyInstaller::Certificate.file}"
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
if File.exist?(cacert)
http.ca_file = cacert
else
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
end
end
yield http
end
Expand Down
12 changes: 12 additions & 0 deletions recipes/certificate.rake
@@ -0,0 +1,12 @@
namespace :certificate do
cert = RubyInstaller::Certificate

source = "#{cert.url}/#{cert.file}"
target = "downloads/#{cert.file}"

download target => source
task :download => target
end

task :certificate => ['certificate:download']
task :downloads => [:certificate]

0 comments on commit 0d02ff8

Please sign in to comment.