diff --git a/pom.xml b/pom.xml
index 37d3bc4..1142113 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,7 +5,7 @@
io.github.theprez
mapepire-server
- 2.1.5
+ 2.1.6
Mapepire (IBM i) Server Component
Server-side support for Mapepire cloud-native database access layer.
https://github.com/Mapepire-IBMi/mapepire-server/
diff --git a/src/main/java/com/github/ibm/mapepire/certstuff/LocalHostResolver.java b/src/main/java/com/github/ibm/mapepire/certstuff/LocalHostResolver.java
new file mode 100644
index 0000000..d08cdcd
--- /dev/null
+++ b/src/main/java/com/github/ibm/mapepire/certstuff/LocalHostResolver.java
@@ -0,0 +1,22 @@
+package com.github.ibm.mapepire.certstuff;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.InetAddress;
+
+import com.github.ibm.mapepire.Tracer;
+
+class LocalHostResolver {
+ static String getFQDN() throws IOException {
+ try {
+ return InetAddress.getLocalHost().getCanonicalHostName().toLowerCase();
+ } catch (IOException e) {
+ Tracer.warn(e);
+ Process p = Runtime.getRuntime().exec("/QOpenSys/usr/bin/hostname");
+ try (BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream()))) {
+ return br.readLine().toLowerCase().trim();
+ }
+ }
+ }
+}
diff --git a/src/main/java/com/github/ibm/mapepire/certstuff/SelfSignedCertGenerator.java b/src/main/java/com/github/ibm/mapepire/certstuff/SelfSignedCertGenerator.java
index 87ef28d..0bd7377 100644
--- a/src/main/java/com/github/ibm/mapepire/certstuff/SelfSignedCertGenerator.java
+++ b/src/main/java/com/github/ibm/mapepire/certstuff/SelfSignedCertGenerator.java
@@ -21,8 +21,7 @@ public ServerCertInfo generate(final String _storePassword, final String _keyPas
final File javaHome = new File(System.getProperty("java.home"));
final File keytoolDir = new File(javaHome, "bin");
- final InetAddress localHost = InetAddress.getLocalHost();
- final String fqdn = localHost.getHostName();
+ final String fqdn = LocalHostResolver.getFQDN();
final String dname = String.format("cn=%s, ou=Web Socket Server, o=Db2 for IBM i, c=Unknown, st=Unknown", fqdn);
final File keytoolPath = new File(keytoolDir, getKeytoolBinaryName());
final String[] cmdArray = new String[] {
diff --git a/src/main/java/com/github/ibm/mapepire/certstuff/ServerCertGetter.java b/src/main/java/com/github/ibm/mapepire/certstuff/ServerCertGetter.java
index 65e0e4a..0c5d959 100644
--- a/src/main/java/com/github/ibm/mapepire/certstuff/ServerCertGetter.java
+++ b/src/main/java/com/github/ibm/mapepire/certstuff/ServerCertGetter.java
@@ -72,7 +72,7 @@ private File findLetsEncryptCertDir() {
}
try {
- String myHostName = InetAddress.getLocalHost().getCanonicalHostName().toLowerCase();
+ String myHostName = LocalHostResolver.getFQDN();
Tracer.info("------we think our hostname is "+myHostName);
for (File candidate : candidates) {
if (candidate.getName().equalsIgnoreCase(myHostName)) {