@@ -374,6 +374,9 @@ def test_set_custom_params
374374-----END CERTIFICATE-----
375375 EOF
376376
377+ require 'time'
378+ VERIFY_EXPIRED_TIME = Time . parse ( "2021/10/20 09:10:00" )
379+
377380 def test_cert_verify_expired1_lets_encrypt_cross_signed_root
378381 # reproducer for https://github.com/jruby/jruby-openssl/issues/236
379382 #
@@ -392,6 +395,7 @@ def test_cert_verify_expired1_lets_encrypt_cross_signed_root
392395 ]
393396
394397 cert_store = OpenSSL ::X509 ::Store . new
398+ cert_store . time = VERIFY_EXPIRED_TIME
395399 root_bundle . each { |cert | cert_store . add_cert cert }
396400
397401 # the endpoint will send the leaf node + these two intermediate certs
@@ -449,6 +453,7 @@ def test_cert_verify_expired2_lets_encrypt_cross_signed_intermediate
449453 ]
450454
451455 cert_store = OpenSSL ::X509 ::Store . new
456+ cert_store . time = VERIFY_EXPIRED_TIME
452457 root_bundle . each { |cert | cert_store . add_cert cert }
453458
454459 # cross-signed cert is sent from the server :
@@ -484,6 +489,7 @@ def test_cert_verify_expired0_lets_encrypt # base_line
484489 ]
485490
486491 cert_store = OpenSSL ::X509 ::Store . new
492+ cert_store . time = VERIFY_EXPIRED_TIME
487493 root_bundle . each { |cert | cert_store . add_cert cert }
488494
489495 chain = [
@@ -501,6 +507,15 @@ def test_cert_verify_expired0_lets_encrypt # base_line
501507 "/C=US/O=Let's Encrypt/CN=R3" ,
502508 "/C=US/O=Internet Security Research Group/CN=ISRG Root X1" ] ,
503509 cert_store . chain . map { |cert | cert . subject . to_s }
510+
511+ cert_store = OpenSSL ::X509 ::Store . new
512+ cert_store . time = VERIFY_EXPIRED_TIME
513+ cert_store . add_cert root_bundle [ 1 ] # only the expired one
514+
515+ ok = cert_store . verify ( LEAF_CERTIFICATE , chain )
516+
517+ assert !ok
518+ assert_equal 'unable to get issuer certificate' , cert_store . error_string
504519 end
505520
506521end
0 commit comments