Skip to content

Ghidra is a software reverse engineering (SRE) framework

GP-0 Corrected Ghidra Server tests to include subject alternative names

ghidra109f14c92d3da
diff --git a/Ghidra/Test/IntegrationTest/src/test.slow/java/ghidra/server/remote/ServerTestUtil.java b/Ghidra/Test/IntegrationTest/src/test.slow/java/ghidra/server/remote/ServerTestUtil.java
index 2728663074..5aebdaa0d7 100644
--- a/Ghidra/Test/IntegrationTest/src/test.slow/java/ghidra/server/remote/ServerTestUtil.java
+++ b/Ghidra/Test/IntegrationTest/src/test.slow/java/ghidra/server/remote/ServerTestUtil.java
@@ -20,7 +20,7 @@ import java.net.*;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.security.KeyStore.PrivateKeyEntry;
-import java.util.ArrayList;
+import java.util.*;
import java.util.function.Consumer;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
@@ -955,7 +955,25 @@ public class ServerTestUtil {
TEST_PKI_SERVER_PASSPHRASE + "): " + serverKeystorePath);
PKIUtils.createKeyEntry("test-sig", TEST_PKI_SERVER_DN, 2, caEntry, serverKeystoreFile,
- "PKCS12", null, TEST_PKI_SERVER_PASSPHRASE.toCharArray());
+ "PKCS12", getLocalHostnames(), TEST_PKI_SERVER_PASSPHRASE.toCharArray());
+ }
+
+ private static Collection<String> getLocalHostnames() throws SocketException {
+
+ // Collect alternate hostnames for inclusion in certificate
+ Set<String> altNames = new TreeSet<>();
+ Enumeration<NetworkInterface> nets = NetworkInterface.getNetworkInterfaces();
+ while (nets.hasMoreElements()) {
+ NetworkInterface netint = nets.nextElement();
+ Enumeration<InetAddress> addrs = netint.getInetAddresses();
+ while (addrs.hasMoreElements()) {
+ InetAddress addr = addrs.nextElement();
+ altNames.add(addr.getHostAddress());
+ altNames.add(addr.getHostName());
+ altNames.add(addr.getCanonicalHostName());
+ }
+ }
+ return altNames;
}
/**