Skip to content

Commit 6701f8e

Browse files
committed
at least OpenSSL.debug potential env read failure on set_default_paths
1 parent 493c28f commit 6701f8e

File tree

3 files changed

+19
-16
lines changed

3 files changed

+19
-16
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,11 +216,11 @@ static void debugStackTrace(final Ruby runtime, final Throwable e) {
216216
if ( isDebug(runtime) ) e.printStackTrace(runtime.getOut());
217217
}
218218

219-
static void debug(final Ruby runtime, final String msg) {
219+
public static void debug(final Ruby runtime, final String msg) {
220220
if ( isDebug(runtime) ) runtime.getOut().println(msg);
221221
}
222222

223-
static void debug(final Ruby runtime, final String msg, final Throwable e) {
223+
public static void debug(final Ruby runtime, final String msg, final Throwable e) {
224224
if ( isDebug(runtime) ) runtime.getOut().println(msg + ' ' + e);
225225
}
226226

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

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

30+
import org.jruby.ext.openssl.OpenSSL;
3031
import org.jruby.ext.openssl.util.Cache;
3132
import static org.jruby.ext.openssl.x509store.X509Utils.X509_CERT_DIR;
3233
import static org.jruby.ext.openssl.x509store.X509Utils.X509_FILETYPE_ASN1;
@@ -356,10 +357,10 @@ public int loadDefaultJavaCACertsFile(String certsFile) throws IOException, Gene
356357
final FileInputStream fin = new FileInputStream(certsFile);
357358
int count = 0;
358359
try {
359-
// hardcode the keystore type, as we expcet cacerts to be a java
360-
// keystore - especially needed for jdk9
360+
// hardcode the keystore type, as we expect cacerts to be a java
361+
// keystore - especially needed for jdk9
361362
KeyStore keystore = SecurityHelper.getKeyStore("jks");
362-
// we pass a null password, as the cacerts file isn't password protected
363+
// null password - as the cacerts file isn't password protected
363364
keystore.load(fin, null);
364365
PKIXParameters params = new PKIXParameters(keystore);
365366
for ( TrustAnchor trustAnchor : params.getTrustAnchors() ) {
@@ -515,9 +516,11 @@ public int call(final Lookup ctx, final Integer cmd, final String argp, final Nu
515516
case X509_L_FILE_LOAD:
516517
if (arglInt == X509_FILETYPE_DEFAULT) {
517518
try {
518-
file = ctx.envEntry( getDefaultCertificateFileEnvironment() );
519+
file = ctx.envEntry( getDefaultCertificateFileEnvironment() ); // ENV['SSL_CERT_FILE']
520+
}
521+
catch (RuntimeException e) {
522+
OpenSSL.debug(ctx.runtime, "failed to read SSL_CERT_FILE", e);
519523
}
520-
catch (RuntimeException e) { }
521524
if (file == null) {
522525
file = X509Utils.X509_CERT_FILE.replace('/', File.separatorChar);
523526
}

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,15 @@
3737
public class LookupMethod {
3838
public String name;
3939

40-
static interface NewItemFunction extends Function1<Lookup> {}
41-
static interface FreeFunction extends Function1<Lookup> {}
42-
static interface InitFunction extends Function1<Lookup> {}
43-
static interface ShutdownFunction extends Function1<Lookup> {}
44-
static interface ControlFunction extends Function5<Lookup, Integer, String, Number, String[]> {}
45-
static interface BySubjectFunction extends Function4<Lookup, Integer, Name, X509Object[]> {}
46-
static interface ByIssuerSerialNumberFunction extends Function5<Lookup, Integer, Name, BigInteger, X509Object[]> {}
47-
static interface ByFingerprintFunction extends Function4<Lookup, Integer, String, X509Object[]> {}
48-
static interface ByAliasFunction extends Function4<Lookup, Integer, String, X509Object[]> {}
40+
interface NewItemFunction extends Function1<Lookup> {}
41+
interface FreeFunction extends Function1<Lookup> {}
42+
interface InitFunction extends Function1<Lookup> {}
43+
interface ShutdownFunction extends Function1<Lookup> {}
44+
interface ControlFunction extends Function5<Lookup, Integer, String, Number, String[]> {}
45+
interface BySubjectFunction extends Function4<Lookup, Integer, Name, X509Object[]> {}
46+
interface ByIssuerSerialNumberFunction extends Function5<Lookup, Integer, Name, BigInteger, X509Object[]> {}
47+
interface ByFingerprintFunction extends Function4<Lookup, Integer, String, X509Object[]> {}
48+
interface ByAliasFunction extends Function4<Lookup, Integer, String, X509Object[]> {}
4949

5050
/**
5151
* c: new_item

0 commit comments

Comments
 (0)