File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed
main/java/org/jruby/ext/openssl/x509store Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change 3232import static org .jruby .ext .openssl .x509store .X509Utils .X509_R_CERT_ALREADY_IN_HASH_TABLE ;
3333
3434import java .io .FileNotFoundException ;
35+ import java .io .IOException ;
3536import java .security .cert .X509Certificate ;
3637import java .util .ArrayList ;
3738import java .util .Arrays ;
@@ -372,6 +373,12 @@ public int setDefaultPaths(Ruby runtime) throws Exception {
372373 catch (FileNotFoundException e ) {
373374 // set_default_paths ignores FileNotFound
374375 }
376+ catch (IOException e ) {
377+ if (!e .getClass ().getSimpleName ().equals ("NotFound" )) {
378+ throw e ;
379+ }
380+ // set_default_paths ignores FileNotFound
381+ }
375382
376383 lookup = addLookup (runtime , Lookup .hashDirLookup ());
377384 //if ( lookup == null ) return 0;
@@ -382,6 +389,12 @@ public int setDefaultPaths(Ruby runtime) throws Exception {
382389 catch (FileNotFoundException e ) {
383390 // set_default_paths ignores FileNotFound
384391 }
392+ catch (IOException e ) {
393+ if (!e .getClass ().getSimpleName ().equals ("NotFound" )) {
394+ throw e ;
395+ }
396+ // set_default_paths ignores FileNotFound
397+ }
385398
386399 X509Error .clearErrors ();
387400 return 1 ;
Original file line number Diff line number Diff line change @@ -55,6 +55,13 @@ def test_add_file_to_store_with_custom_cert_file
5555 assert store . verify ( OpenSSL ::X509 ::Certificate . new ( File . read ( @pem ) ) )
5656 end
5757
58+ def test_use_non_existing_cert_file
59+ ENV [ 'SSL_CERT_FILE' ] = 'non-existing-file.crt'
60+ store = OpenSSL ::X509 ::Store . new
61+ store . set_default_paths
62+ assert !store . verify ( @cert )
63+ end
64+
5865 def test_verfy_with_wrong_argument
5966 store = OpenSSL ::X509 ::Store . new
6067 assert_raise ( TypeError ) { store . verify ( 'not an cert object' ) }
You can’t perform that action at this time.
0 commit comments