Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions certificate-analyser/src/main/java/org/zowe/apiml/Analyser.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
public class Analyser {

public static int mainWithExitCode(String[] args) {
ensureSafkeyringHandler();
try {
ApimlConf conf = new ApimlConf();
CommandLine cmd = new CommandLine(conf);
Expand Down Expand Up @@ -62,6 +63,20 @@ public static int mainWithExitCode(String[] args) {
return 4;
}

/**
* Registers the IBM SAF keyring URL protocol handler so that
* {@code new URL("safkeyring://...")} works on z/OS without requiring the
* caller to pass {@code -Djava.protocol.handler.pkgs=com.ibm.crypto.provider}.
* On non-z/OS platforms the handler class is simply not found and is ignored.
*/
static void ensureSafkeyringHandler() {
String existing = System.getProperty("java.protocol.handler.pkgs", "");
if (!existing.contains("com.ibm.crypto.provider")) {
System.setProperty("java.protocol.handler.pkgs",
existing.isEmpty() ? "com.ibm.crypto.provider" : existing + "|com.ibm.crypto.provider");
}
}

public static final void main(String[] args) {
System.exit(mainWithExitCode(args));
}
Expand Down
10 changes: 8 additions & 2 deletions certificate-analyser/src/main/java/org/zowe/apiml/Stores.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,14 @@ private void initTruststore() throws IOException, CertificateException, NoSuchAl
}
return;
}
try (InputStream trustStoreIStream = new FileInputStream(conf.getTrustStore())) {
this.trustStore = readKeyStore(trustStoreIStream, conf.getTrustPasswd().toCharArray(), conf.getTrustStoreType());
if (isKeyring(conf.getTrustStore())) {
try (InputStream trustStoreIStream = keyRingUrl(conf.getTrustStore()).openStream()) {
this.trustStore = readKeyStore(trustStoreIStream, conf.getTrustPasswd().toCharArray(), conf.getTrustStoreType());
}
} else {
try (InputStream trustStoreIStream = new FileInputStream(conf.getTrustStore())) {
this.trustStore = readKeyStore(trustStoreIStream, conf.getTrustPasswd().toCharArray(), conf.getTrustStoreType());
}
}

}
Expand Down
Loading