diff options
author | Kenny Root <kroot@google.com> | 2015-06-10 10:20:30 -0700 |
---|---|---|
committer | Kenny Root <kroot@google.com> | 2015-06-10 11:05:52 -0700 |
commit | 229d56846bd56df1b2b6942a25127003bde88222 (patch) | |
tree | 333afb513e4c1c544a5d429c498adabd49e7a65c | |
parent | 03814a0f775cee3003bba03d3617bcd5ea727d8b (diff) | |
download | libcore-229d56846bd56df1b2b6942a25127003bde88222.zip libcore-229d56846bd56df1b2b6942a25127003bde88222.tar.gz libcore-229d56846bd56df1b2b6942a25127003bde88222.tar.bz2 |
SSLEngineTest: set up server instead of using anon
This test was relying on "anon" cipher suites so that it didn't have to
do any complicated setup of the server certificate store. Fortunately we
already have a utility class we can use that does this setup for us so
there is no need to rely on anonymous cipher suites that do no
authentication.
(cherry picked from commit 5be4c97a83895b7e1385445db6a1717eb8df3e9b)
Bug: 21195269
Change-Id: I30bf4cd3b99bf946887cca293d616021cfce1bd7
-rw-r--r-- | harmony-tests/src/test/java/org/apache/harmony/tests/javax/net/ssl/SSLEngineTest.java | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/harmony-tests/src/test/java/org/apache/harmony/tests/javax/net/ssl/SSLEngineTest.java b/harmony-tests/src/test/java/org/apache/harmony/tests/javax/net/ssl/SSLEngineTest.java index 8f68d6e..9360c00 100644 --- a/harmony-tests/src/test/java/org/apache/harmony/tests/javax/net/ssl/SSLEngineTest.java +++ b/harmony-tests/src/test/java/org/apache/harmony/tests/javax/net/ssl/SSLEngineTest.java @@ -36,6 +36,7 @@ import javax.net.ssl.SSLException; import javax.net.ssl.SSLEngineResult.HandshakeStatus; import junit.framework.TestCase; import libcore.java.security.StandardNames; +import libcore.javax.net.ssl.TestSSLContext; /** * Tests for SSLEngine class @@ -1042,21 +1043,12 @@ public class SSLEngineTest extends TestCase { private ByteBuffer writeBuffer; - HandshakeHandler(boolean clientMode, SourceChannel in, SinkChannel out) throws Exception { + HandshakeHandler(SSLContext context, boolean clientMode, SourceChannel in, SinkChannel out) + throws Exception { this.in = in; this.out = out; - engine = getEngine(); + engine = context.createSSLEngine(); engine.setUseClientMode(clientMode); - String[] cipherSuites = engine.getSupportedCipherSuites(); - Set<String> enabledSuites = new HashSet<String>(); - for (String cipherSuite : cipherSuites) { - if (cipherSuite.contains("anon")) { - enabledSuites.add(cipherSuite); - } - } - engine.setEnabledCipherSuites((String[]) enabledSuites.toArray( - new String[enabledSuites.size()])); - engine.beginHandshake(); status = engine.getHandshakeStatus(); @@ -1179,8 +1171,9 @@ public class SSLEngineTest extends TestCase { SinkChannel serverSink = serverSendPipe.sink(); SourceChannel clientSource = serverSendPipe.source(); - clientEngine = new HandshakeHandler(true, clientSource, clientSink); - serverEngine = new HandshakeHandler(false, serverSource, serverSink); + TestSSLContext context = TestSSLContext.create(); + clientEngine = new HandshakeHandler(context.clientContext, true, clientSource, clientSink); + serverEngine = new HandshakeHandler(context.serverContext, false, serverSource, serverSink); } boolean doHandshake() throws InterruptedException { |