File tree Expand file tree Collapse file tree 1 file changed +22
-1
lines changed
Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -92,7 +92,7 @@ def test_add_cert_concurrently
9292 assert true
9393 end
9494
95- define_method 'test_add_same_cert_twice jruby/jruby-openssl/issues/ 3' do
95+ define_method 'test_add_same_cert_twice jruby/jruby-openssl# 3' do
9696 root_key = OpenSSL ::PKey ::RSA . new 2048 # the CA's public/private key
9797 root_ca = OpenSSL ::X509 ::Certificate . new
9898 root_ca . version = 2 # cf. RFC 5280 - to make it a "v3" certificate
@@ -121,4 +121,25 @@ def test_add_cert_concurrently
121121 end
122122 end
123123
124+ def test_adding_pem_to_store
125+ debug = false
126+ #OpenSSL.debug = true
127+ # mimic what rubygems/request#add_rubygems_trusted_certs does to find the .pem certificates
128+ # 1.7: jruby-complete-1.7.22.jar!/META-INF/jruby.home/lib/ruby/shared
129+ # 9.0: /opt/local/rvm/rubies/jruby-9.0.4.0/lib/ruby/stdlib
130+ base = $LOAD_PATH. detect { |p | p =~ /ruby\/ shared/ || p =~ /ruby\/ stdlib/ }
131+ raise "rubygems home not detected in $LOAD_PATH" unless base
132+ pems = Dir [ File . join ( base , 'rubygems/ssl_certs/*pem' ) ]
133+ # assert_equal( 9, pems.size ) # >= 11 on 9K
134+ pems . each do |pem |
135+ puts pem . inspect if debug
136+ store = OpenSSL ::X509 ::Store . new
137+ cert = OpenSSL ::X509 ::Certificate . new ( File . read ( pem ) )
138+ assert ! store . verify ( cert )
139+ store . add_file ( pem )
140+ # only verify on self signed certifactes
141+ assert store . verify ( cert ) if pem !~ /COMODORSA|AddTrustExternalCARoot/
142+ end
143+ end
144+
124145end
You can’t perform that action at this time.
0 commit comments