summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--support/src/test/java/libcore/java/security/TestKeyStore.java9
-rw-r--r--support/src/test/java/libcore/javax/net/ssl/TestSSLContext.java6
2 files changed, 9 insertions, 6 deletions
diff --git a/support/src/test/java/libcore/java/security/TestKeyStore.java b/support/src/test/java/libcore/java/security/TestKeyStore.java
index 17b8be5..30e40fb 100644
--- a/support/src/test/java/libcore/java/security/TestKeyStore.java
+++ b/support/src/test/java/libcore/java/security/TestKeyStore.java
@@ -30,13 +30,14 @@ import java.io.ByteArrayInputStream;
import java.io.PrintStream;
import java.math.BigInteger;
import java.net.InetAddress;
+import java.net.UnknownHostException;
import java.security.KeyFactory;
import java.security.KeyPair;
import java.security.KeyPairGenerator;
+import java.security.KeyStore;
import java.security.KeyStore.PasswordProtection;
import java.security.KeyStore.PrivateKeyEntry;
import java.security.KeyStore.TrustedCertificateEntry;
-import java.security.KeyStore;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.Principal;
@@ -438,7 +439,11 @@ public final class TestKeyStore extends Assert {
}
private X500Principal localhost() {
- return new X500Principal("CN=" + InetAddress.getLoopbackAddress().getHostName());
+ try {
+ return new X500Principal("CN=" + InetAddress.getLocalHost().getHostName());
+ } catch (UnknownHostException e) {
+ throw new RuntimeException(e);
+ }
}
}
diff --git a/support/src/test/java/libcore/javax/net/ssl/TestSSLContext.java b/support/src/test/java/libcore/javax/net/ssl/TestSSLContext.java
index e1af9e2..5c424bc 100644
--- a/support/src/test/java/libcore/javax/net/ssl/TestSSLContext.java
+++ b/support/src/test/java/libcore/javax/net/ssl/TestSSLContext.java
@@ -18,7 +18,6 @@ package libcore.javax.net.ssl;
import java.io.IOException;
import java.net.InetAddress;
-import java.net.InetSocketAddress;
import java.net.Socket;
import java.net.UnknownHostException;
import java.security.KeyStore;
@@ -176,9 +175,8 @@ public final class TestSSLContext extends Assert {
try {
SSLServerSocket serverSocket = (SSLServerSocket)
serverContext.getServerSocketFactory().createServerSocket(0);
- InetSocketAddress sa = (InetSocketAddress) serverSocket.getLocalSocketAddress();
- InetAddress host = sa.getAddress();
- int port = sa.getPort();
+ InetAddress host = InetAddress.getLocalHost();
+ int port = serverSocket.getLocalPort();
return new TestSSLContext(clientKeyStore, clientStorePassword,
serverKeyStore, serverStorePassword,