2727 ***** END LICENSE BLOCK *****/
2828package org .jruby .ext .openssl .x509store ;
2929
30+
31+ import static org .jruby .ext .openssl .OpenSSL .debugStackTrace ;
32+
3033import org .jruby .ext .openssl .util .Cache ;
3134import static org .jruby .ext .openssl .x509store .X509Utils .X509_CERT_DIR ;
3235import static org .jruby .ext .openssl .x509store .X509Utils .X509_FILETYPE_ASN1 ;
@@ -239,6 +242,10 @@ else if ( type == X509_FILETYPE_ASN1 ) {
239242 return 0 ; // NOTE: really?
240243 }
241244 }
245+ catch (IOException e ) {
246+ debugStackTrace (runtime , e );
247+ return 0 ;
248+ }
242249 finally {
243250 if ( reader != null ) {
244251 try { reader .close (); } catch (Exception ignored ) {}
@@ -285,6 +292,10 @@ else if ( type == X509_FILETYPE_ASN1 ) {
285292 return 0 ; // NOTE: really?
286293 }
287294 }
295+ catch (IOException e ) {
296+ debugStackTrace (runtime , e );
297+ return 0 ;
298+ }
288299 finally {
289300 if ( reader != null ) {
290301 try { reader .close (); } catch (Exception ignored ) {}
@@ -345,6 +356,10 @@ else if ( cert instanceof CRL ) {
345356 }
346357 return count ;
347358 }
359+ catch (IOException e ) {
360+ debugStackTrace (runtime , e );
361+ return 0 ;
362+ }
348363 finally {
349364 if ( reader != null ) {
350365 try { reader .close (); } catch (Exception ignored ) {}
@@ -367,6 +382,9 @@ public int loadDefaultJavaCACertsFile() throws IOException, GeneralSecurityExcep
367382 count ++;
368383 }
369384 }
385+ catch (IOException e ) {
386+ return 0 ;
387+ }
370388 finally {
371389 try { fin .close (); } catch (Exception ignored ) {}
372390 }
@@ -522,6 +540,10 @@ public int call(final Lookup ctx, final Integer cmd, final String argp, final Nu
522540 ok = ctx .loadCertificateOrCRLFile (file , X509_FILETYPE_PEM ) != 0 ? 1 : 0 ;
523541 } else {
524542 ok = (ctx .loadDefaultJavaCACertsFile () != 0 ) ? 1 : 0 ;
543+ // it could be a PEM file
544+ if (ok == 0 ) {
545+ ok = ctx .loadCertificateOrCRLFile (file , X509_FILETYPE_PEM ) != 0 ? 1 : 0 ;
546+ }
525547 }
526548 if (ok == 0 ) {
527549 X509Error .addError (X509_R_LOADING_DEFAULTS );
0 commit comments