ruby-changes:36860
From: usa <ko1@a...>
Date: Wed, 24 Dec 2014 00:07:00 +0900 (JST)
Subject: [ruby-changes:36860] usa:r48941 (trunk): * lib/open-uri.rb (OpenURI.open_http): accept multiple certs path in
usa 2014-12-24 00:06:40 +0900 (Wed, 24 Dec 2014) New Revision: 48941 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=48941 Log: * lib/open-uri.rb (OpenURI.open_http): accept multiple certs path in ssl_ca_certs. * tool/downloader.rb: use certs of rubygems for downloading gems. Modified files: trunk/ChangeLog trunk/lib/open-uri.rb trunk/tool/downloader.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 48940) +++ ChangeLog (revision 48941) @@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Wed Dec 24 00:04:45 2014 NAKAMURA Usaku <usa@r...> + + * lib/open-uri.rb (OpenURI.open_http): accept multiple certs path in + ssl_ca_certs. + + * tool/downloader.rb: use certs of rubygems for downloading gems. + Tue Dec 23 22:39:11 2014 Nobuyoshi Nakada <nobu@r...> * ext/fiddle/extlibs: libffi-3.2.1 and patch for mswin. Index: lib/open-uri.rb =================================================================== --- lib/open-uri.rb (revision 48940) +++ lib/open-uri.rb (revision 48941) @@ -295,10 +295,13 @@ module OpenURI https://github.com/ruby/ruby/blob/trunk/lib/open-uri.rb#L295 http.verify_mode = options[:ssl_verify_mode] || OpenSSL::SSL::VERIFY_PEER store = OpenSSL::X509::Store.new if options[:ssl_ca_cert] - if File.directory? options[:ssl_ca_cert] - store.add_path options[:ssl_ca_cert] - else - store.add_file options[:ssl_ca_cert] + certs = options[:ssl_ca_cert].is_a?(Array) ? options[:ssl_ca_cert] : [options[:ssl_ca_cert]] + certs.each do |cert| + if File.directory? cert + store.add_path cert + else + store.add_file cert + end end else store.set_default_paths @@ -680,7 +683,7 @@ module OpenURI https://github.com/ruby/ruby/blob/trunk/lib/open-uri.rb#L683 # # [:ssl_ca_cert] # Synopsis: - # :ssl_ca_cert=>filename + # :ssl_ca_cert=>filename or an Array of filenames # # :ssl_ca_cert is used to specify CA certificate for SSL. # If it is given, default certificates are not used. Index: tool/downloader.rb =================================================================== --- tool/downloader.rb (revision 48940) +++ tool/downloader.rb (revision 48941) @@ -9,7 +9,7 @@ class Downloader https://github.com/ruby/ruby/blob/trunk/tool/downloader.rb#L9 class RubyGems < self def self.download(name, *rest) - super("https://rubygems.org/downloads/#{name}", name, *rest) + super("https://rubygems.org/downloads/#{name}", name, *rest, ssl_ca_cert: Dir.glob(File.expand_path("../lib/rubygems/ssl_certs/*.pem", File.dirname(__FILE__)))) end end @@ -52,7 +52,7 @@ class Downloader https://github.com/ruby/ruby/blob/trunk/tool/downloader.rb#L52 # Example usage: # download 'http://www.unicode.org/Public/UCD/latest/ucd/UnicodeData.txt', # 'UnicodeData.txt', 'enc/unicode/data' - def self.download(url, name, dir = nil, ims = true) + def self.download(url, name, dir = nil, ims = true, options = {}) file = dir ? File.join(dir, File.basename(name)) : name if ims.nil? and File.exist?(file) if $VERBOSE @@ -67,7 +67,7 @@ class Downloader https://github.com/ruby/ruby/blob/trunk/tool/downloader.rb#L67 $stdout.flush end begin - data = url.read(http_options(file, ims.nil? ? true : ims)) + data = url.read(options.merge(http_options(file, ims.nil? ? true : ims))) rescue OpenURI::HTTPError => http_error if http_error.message =~ /^304 / # 304 Not Modified if $VERBOSE -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/