1 /*
2 * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
34 import javax.net.ssl.SSLSocket;
35 import javax.net.ssl.TrustManager;
36
37 class JSSEServer extends CipherTest.Server {
38
39 SSLServerSocket serverSocket;
40
41 JSSEServer(CipherTest cipherTest) throws Exception {
42 super(cipherTest);
43 SSLContext serverContext = SSLContext.getInstance("TLS");
44 serverContext.init(
45 new KeyManager[] { CipherTest.keyManager },
46 new TrustManager[] { CipherTest.trustManager },
47 CipherTest.secureRandom);
48
49 SSLServerSocketFactory factory
50 = (SSLServerSocketFactory) serverContext.getServerSocketFactory();
51 serverSocket
52 = (SSLServerSocket) factory.createServerSocket(CipherTest.serverPort);
53 CipherTest.serverPort = serverSocket.getLocalPort();
54 serverSocket.setEnabledCipherSuites(factory.getSupportedCipherSuites());
55 serverSocket.setWantClientAuth(true);
56 }
57
58 public void run() {
59 System.out.println("JSSE Server listening on port " + CipherTest.serverPort);
60 Executor exec = Executors.newFixedThreadPool
61 (cipherTest.THREADS, DaemonThreadFactory.INSTANCE);
62 try {
63 while (true) {
64 final SSLSocket socket = (SSLSocket)serverSocket.accept();
65 socket.setSoTimeout(CipherTest.TIMEOUT);
66 Runnable r = new Runnable() {
67 public void run() {
68 try {
69 InputStream in = socket.getInputStream();
70 OutputStream out = socket.getOutputStream();
71 handleRequest(in, out);
72 out.flush();
73 socket.close();
|
1 /*
2 * Copyright (c) 2002, 2019, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
34 import javax.net.ssl.SSLSocket;
35 import javax.net.ssl.TrustManager;
36
37 class JSSEServer extends CipherTest.Server {
38
39 SSLServerSocket serverSocket;
40
41 JSSEServer(CipherTest cipherTest) throws Exception {
42 super(cipherTest);
43 SSLContext serverContext = SSLContext.getInstance("TLS");
44 serverContext.init(
45 new KeyManager[] { CipherTest.keyManager },
46 new TrustManager[] { CipherTest.trustManager },
47 CipherTest.secureRandom);
48
49 SSLServerSocketFactory factory
50 = (SSLServerSocketFactory) serverContext.getServerSocketFactory();
51 serverSocket
52 = (SSLServerSocket) factory.createServerSocket(CipherTest.serverPort);
53 CipherTest.serverPort = serverSocket.getLocalPort();
54
55 // JDK-8190492: Enable all supported protocols on server side to test SSLv3
56 serverSocket.setEnabledProtocols(serverSocket.getSupportedProtocols());
57
58 serverSocket.setEnabledCipherSuites(factory.getSupportedCipherSuites());
59 serverSocket.setWantClientAuth(true);
60 }
61
62 public void run() {
63 System.out.println("JSSE Server listening on port " + CipherTest.serverPort);
64 Executor exec = Executors.newFixedThreadPool
65 (cipherTest.THREADS, DaemonThreadFactory.INSTANCE);
66 try {
67 while (true) {
68 final SSLSocket socket = (SSLSocket)serverSocket.accept();
69 socket.setSoTimeout(CipherTest.TIMEOUT);
70 Runnable r = new Runnable() {
71 public void run() {
72 try {
73 InputStream in = socket.getInputStream();
74 OutputStream out = socket.getOutputStream();
75 handleRequest(in, out);
76 out.flush();
77 socket.close();
|