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", "");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in the start.sh scripts for API ML components we have java.protocol.handler.pkgs always set to com.ibm.crypto.provider. Should we have it the same way also for the analyser?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we have the place to push this in, I would say yes.

if (!existing.contains("com.ibm.crypto.provider")) {
System.setProperty("java.protocol.handler.pkgs",
existing.isEmpty() ? "com.ibm.crypto.provider" : existing + "|com.ibm.crypto.provider");
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious if this works with Java 21 too?

}
}

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