mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Fallback to Digest::SHA512
`Gem::Package::TarWriter#add_file_signed` expects to fallback to `Digest::SHA512`, and `digest.respond_to? :name` or not. So lib/rubygems/security.rb should use same logic for `Gem::Security::DIGEST_ALGORITHM` and `Gem::Security::DIGEST_NAME`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63851 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
e4664efaf8
commit
0f24cdec9e
2 changed files with 7 additions and 3 deletions
|
@ -187,8 +187,7 @@ class Gem::Package::TarWriter
|
|||
if digest.respond_to? :name then
|
||||
digest.name
|
||||
else
|
||||
/::([^:]+)$/ =~ digest.class.name
|
||||
$1
|
||||
digest.class.name[/::([^:]+)\z/, 1]
|
||||
end
|
||||
|
||||
digest_name == signer.digest_name
|
||||
|
|
|
@ -344,14 +344,19 @@ module Gem::Security
|
|||
OpenSSL::Digest::SHA256
|
||||
elsif defined?(OpenSSL::Digest::SHA1) then
|
||||
OpenSSL::Digest::SHA1
|
||||
else
|
||||
require 'digest'
|
||||
Digest::SHA512
|
||||
end
|
||||
|
||||
##
|
||||
# Used internally to select the signing digest from all computed digests
|
||||
|
||||
DIGEST_NAME = # :nodoc:
|
||||
if DIGEST_ALGORITHM then
|
||||
if DIGEST_ALGORITHM.method_defined? :name then
|
||||
DIGEST_ALGORITHM.new.name
|
||||
else
|
||||
DIGEST_ALGORITHM.name[/::([^:]+)\z/, 1]
|
||||
end
|
||||
|
||||
##
|
||||
|
|
Loading…
Reference in a new issue