Skip to content

Commit 32977f3

Browse files
rheniumhsbt
authored andcommitted
[rubygems/rubygems] Avoid openssl bug in test_verify_certificate_extra_message
OpenSSL::X509::StoreContext#current_cert returns an empty and invalid OpenSSL::X509::Certificate instance if it is called before starting a certificate verification. https://redirect.github.com/ruby/openssl/pull/919 will change it to return nil instead in such a case. Adjust test_verify_certificate_extra_message to actually complete StoreContext#verify so that it will not rely on this behavior. ruby/rubygems@823799088d
1 parent 2256b0f commit 32977f3

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

test/rubygems/test_gem_request.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -363,19 +363,19 @@ def test_verify_certificate
363363
def test_verify_certificate_extra_message
364364
pend if Gem.java_platform?
365365

366-
error_number = OpenSSL::X509::V_ERR_INVALID_CA
366+
error_number = OpenSSL::X509::V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY
367367

368368
store = OpenSSL::X509::Store.new
369-
context = OpenSSL::X509::StoreContext.new store
370-
context.error = error_number
369+
context = OpenSSL::X509::StoreContext.new store, CHILD_CERT
370+
context.verify
371371

372372
use_ui @ui do
373373
Gem::Request.verify_certificate context
374374
end
375375

376376
expected = <<-ERROR
377-
ERROR: SSL verification error at depth 0: invalid CA certificate (#{error_number})
378-
ERROR: Certificate is an invalid CA certificate
377+
ERROR: SSL verification error at depth 0: unable to get local issuer certificate (#{error_number})
378+
ERROR: You must add #{CHILD_CERT.issuer} to your local trusted store
379379
ERROR
380380

381381
assert_equal expected, @ui.error

0 commit comments

Comments
 (0)