From 67f59eb4abd6ee02ee25d379de70d43533bce87b Mon Sep 17 00:00:00 2001 From: naruse Date: Fri, 14 Dec 2018 08:01:40 +0000 Subject: [PATCH] fix r66163 OpenSSL maybe aren't loaded in rubygems. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66400 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/rubygems/remote_fetcher.rb | 3 ++- test/rubygems/test_gem_remote_fetcher.rb | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/lib/rubygems/remote_fetcher.rb b/lib/rubygems/remote_fetcher.rb index 639ea3c19d..69879df67c 100644 --- a/lib/rubygems/remote_fetcher.rb +++ b/lib/rubygems/remote_fetcher.rb @@ -274,7 +274,8 @@ class Gem::RemoteFetcher raise rescue Timeout::Error raise UnknownHostError.new('timed out', uri.to_s) - rescue IOError, SocketError, SystemCallError, OpenSSL::SSL::SSLError => e + rescue IOError, SocketError, SystemCallError, + *(OpenSSL::SSL::SSLError if defined?(OpenSSL)) => e if e.message =~ /getaddrinfo/ raise UnknownHostError.new('no such name', uri.to_s) else diff --git a/test/rubygems/test_gem_remote_fetcher.rb b/test/rubygems/test_gem_remote_fetcher.rb index ad99783c64..5029a6a6fd 100644 --- a/test/rubygems/test_gem_remote_fetcher.rb +++ b/test/rubygems/test_gem_remote_fetcher.rb @@ -516,6 +516,24 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg== assert_equal url, e.uri end + def test_fetch_path_openssl_ssl_sslerror + fetcher = Gem::RemoteFetcher.new nil + @fetcher = fetcher + + def fetcher.fetch_http(uri, mtime = nil, head = nil) + raise OpenSSL::SSL::SSLError + end + + url = 'http://example.com/uri' + + e = assert_raises Gem::RemoteFetcher::FetchError do + fetcher.fetch_path url + end + + assert_equal "OpenSSL::SSL::SSLError: OpenSSL::SSL::SSLError (#{url})", e.message + assert_equal url, e.uri + end + def test_fetch_path_unmodified fetcher = Gem::RemoteFetcher.new nil @fetcher = fetcher