Skip to content

Commit

Permalink
Raise an explicit error if Signer#sign is called with no certs, and a…
Browse files Browse the repository at this point in the history
…dd a test for it.
  • Loading branch information
Daniel Berger committed Apr 29, 2016
1 parent 9c11011 commit fff6e78
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/rubygems/security/signer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ def load_cert_chain # :nodoc:
def sign data
return unless @key

raise Gem::Security::Exception, 'no certs provided' if @cert_chain.empty?

if @cert_chain.length == 1 and @cert_chain.last.not_after < Time.now then
re_sign_key
end
Expand Down
8 changes: 8 additions & 0 deletions test/rubygems/test_gem_security_signer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -205,5 +205,13 @@ def test_sign_wrong_key
end
end

def test_sign_no_certs
signer = Gem::Security::Signer.new ALTERNATE_KEY, []

assert_raises Gem::Security::Exception do
signer.sign 'hello'
end
end

end if defined?(OpenSSL::SSL)

0 comments on commit fff6e78

Please sign in to comment.