summaryrefslogtreecommitdiffstats
path: root/support
diff options
context:
space:
mode:
authorJesse Wilson <jessewilson@google.com>2011-06-08 17:33:13 -0700
committerJesse Wilson <jessewilson@google.com>2011-06-08 17:33:13 -0700
commit547450702efd233213f953ba2213bb38803c34c3 (patch)
tree26e08660c834634549c5d6e0be664784e4ae7991 /support
parent6abb9fbb22a2847d2cd545462c33aeb986c0402d (diff)
downloadlibcore-547450702efd233213f953ba2213bb38803c34c3.zip
libcore-547450702efd233213f953ba2213bb38803c34c3.tar.gz
libcore-547450702efd233213f953ba2213bb38803c34c3.tar.bz2
Use the same host name in the SSL cert as in mockwebserver.
MockWebServer had to revert to getLocalHost() since 'getLoopbackAddress() doesn't exist on Java 6 and MockWebServer wants to work on Java 6. Tested on host and device without problem. Change-Id: Ib083ec393d34b2378da579ffc7b6a71d599f9d22
Diffstat (limited to 'support')
-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,