Skip to content

Commit 09f14c9

Browse files
committed
GP-0 Corrected Ghidra Server tests to include subject alternative names
1 parent cb8f6e2 commit 09f14c9

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

Ghidra/Test/IntegrationTest/src/test.slow/java/ghidra/server/remote/ServerTestUtil.java

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import java.rmi.registry.LocateRegistry;
2121
import java.rmi.registry.Registry;
2222
import java.security.KeyStore.PrivateKeyEntry;
23-
import java.util.ArrayList;
23+
import java.util.*;
2424
import java.util.function.Consumer;
2525
import java.util.zip.ZipEntry;
2626
import java.util.zip.ZipInputStream;
@@ -955,7 +955,25 @@ private static void generatePkiCerts() throws Exception {
955955
TEST_PKI_SERVER_PASSPHRASE + "): " + serverKeystorePath);
956956

957957
PKIUtils.createKeyEntry("test-sig", TEST_PKI_SERVER_DN, 2, caEntry, serverKeystoreFile,
958-
"PKCS12", null, TEST_PKI_SERVER_PASSPHRASE.toCharArray());
958+
"PKCS12", getLocalHostnames(), TEST_PKI_SERVER_PASSPHRASE.toCharArray());
959+
}
960+
961+
private static Collection<String> getLocalHostnames() throws SocketException {
962+
963+
// Collect alternate hostnames for inclusion in certificate
964+
Set<String> altNames = new TreeSet<>();
965+
Enumeration<NetworkInterface> nets = NetworkInterface.getNetworkInterfaces();
966+
while (nets.hasMoreElements()) {
967+
NetworkInterface netint = nets.nextElement();
968+
Enumeration<InetAddress> addrs = netint.getInetAddresses();
969+
while (addrs.hasMoreElements()) {
970+
InetAddress addr = addrs.nextElement();
971+
altNames.add(addr.getHostAddress());
972+
altNames.add(addr.getHostName());
973+
altNames.add(addr.getCanonicalHostName());
974+
}
975+
}
976+
return altNames;
959977
}
960978

961979
/**

0 commit comments

Comments
 (0)