summaryrefslogtreecommitdiff
path: root/tool/downloader.rb
diff options
context:
space:
mode:
authornagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-08-18 13:55:46 +0000
committernagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-08-18 13:55:46 +0000
commitb8c7ea548aa8fb5f3c399a00ce877d3431c27a01 (patch)
tree71dd1993eac7b198ed1bdd52e7eda40be671caf5 /tool/downloader.rb
parentacaf2ee762b08a4ccb23fef46cd93da1616d4d32 (diff)
parenta627fdfaaffd456de871ead092c1770d220aec98 (diff)
add tag v2_2_3v2_2_3
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/tags/v2_2_3@51636 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'tool/downloader.rb')
-rw-r--r--tool/downloader.rb34
1 files changed, 33 insertions, 1 deletions
diff --git a/tool/downloader.rb b/tool/downloader.rb
index dd3173bae7..8f169d5849 100644
--- a/tool/downloader.rb
+++ b/tool/downloader.rb
@@ -1,4 +1,33 @@
require 'open-uri'
+begin
+ require 'net/https'
+ $rubygems_schema = 'https'
+
+ # open-uri of ruby 2.2.0 accept an array of PEMs as ssl_ca_cert, but old
+ # versions are not. so, patching OpenSSL::X509::Store#add_file instead.
+ class OpenSSL::X509::Store
+ alias orig_add_file add_file
+ def add_file(pems)
+ Array(pems).each do |pem|
+ if File.directory?(pem)
+ add_path pem
+ else
+ orig_add_file pem
+ end
+ end
+ end
+ end
+ # since open-uri internally checks ssl_ca_cert by File.directory?, to allow
+ # accept an array.
+ class <<File
+ alias orig_directory? directory?
+ def File.directory? files
+ files.is_a?(Array) ? false : orig_directory?(files)
+ end
+ end
+rescue LoadError
+ $rubygems_schema = 'http'
+end
class Downloader
class GNU < self
@@ -10,7 +39,10 @@ class Downloader
class RubyGems < self
def self.download(name, dir = nil, ims = true, options = {})
options[:ssl_ca_cert] = Dir.glob(File.expand_path("../lib/rubygems/ssl_certs/*.pem", File.dirname(__FILE__)))
- super("https://rubygems.org/downloads/#{name}", name, dir, ims, options)
+ if $rubygems_schema != 'https'
+ warn "*** using http instead of https ***"
+ end
+ super("#{$rubygems_schema}://rubygems.org/downloads/#{name}", name, dir, ims, options)
end
end