Skip to content

Commit 1d3ba21

Browse files
committed
the default cert could be PEM or a java keystore. it should load both whatver is used as default.
1 parent 1b5dbbe commit 1d3ba21

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

lib/jopenssl/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module Jopenssl
22
module Version
3-
VERSION = '0.9.9'
3+
VERSION = '0.9.10'
44
BOUNCY_CASTLE_VERSION = '1.50'
55
end
66
end

src/main/java/org/jruby/ext/openssl/OpenSSL.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ static boolean isDebug(final Ruby runtime) {
205205
return getDebug( OpenSSL ) == runtime.getTrue();
206206
}
207207

208-
static void debugStackTrace(final Ruby runtime, final Throwable e) {
208+
public static void debugStackTrace(final Ruby runtime, final Throwable e) {
209209
if ( isDebug(runtime) ) e.printStackTrace(runtime.getOut());
210210
}
211211

src/main/java/org/jruby/ext/openssl/x509store/Lookup.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
2727
***** END LICENSE BLOCK *****/
2828
package org.jruby.ext.openssl.x509store;
2929

30+
31+
import static org.jruby.ext.openssl.OpenSSL.debugStackTrace;
32+
3033
import org.jruby.ext.openssl.util.Cache;
3134
import static org.jruby.ext.openssl.x509store.X509Utils.X509_CERT_DIR;
3235
import 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

Comments
 (0)