diff options
Diffstat (limited to 'lib/rubygems/remote_fetcher.rb')
-rw-r--r-- | lib/rubygems/remote_fetcher.rb | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/lib/rubygems/remote_fetcher.rb b/lib/rubygems/remote_fetcher.rb index 6650711235..37699d17fc 100644 --- a/lib/rubygems/remote_fetcher.rb +++ b/lib/rubygems/remote_fetcher.rb @@ -321,13 +321,24 @@ class Gem::RemoteFetcher if https?(uri) and !connection.started? then configure_connection_for_https(connection) - end - connection.start unless connection.started? + # Don't refactor this with the else branch. We don't want the + # http-only code path to not depend on anything in OpenSSL. + # + begin + connection.start + rescue OpenSSL::SSL::SSLError, Errno::EHOSTDOWN => e + raise FetchError.new(e.message, uri) + end + else + begin + connection.start unless connection.started? + rescue Errno::EHOSTDOWN => e + raise FetchError.new(e.message, uri) + end + end connection - rescue OpenSSL::SSL::SSLError, Errno::EHOSTDOWN => e - raise FetchError.new(e.message, uri) end def configure_connection_for_https(connection) |