提交 f4b0beeb 编写于 作者: X xuelei

8001569: Regression test GetPeerHost uses static port number

Reviewed-by: weijun
上级 fe336b37
/*
* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -21,13 +21,15 @@
* questions.
*/
//
// SunJSSE does not support dynamic system properties, no way to re-use
// system properties in samevm/agentvm mode.
//
/**
* @test
* @bug 4302026
* @run main/othervm GetPeerHost
*
* SunJSSE does not support dynamic system properties, no way to re-use
* system properties in samevm/agentvm mode.
* @summary make sure the server side doesn't do DNS lookup.
*/
import javax.net.*;
......@@ -41,7 +43,8 @@ public class GetPeerHost {
+ "/../../../../../../../etc/truststore");
GetPeerHostServer server = new GetPeerHostServer();
server.start();
GetPeerHostClient client = new GetPeerHostClient();
GetPeerHostClient client =
new GetPeerHostClient(server.getServerPort());
client.start();
server.join ();
if (!server.getPassStatus ()) {
......
/*
* Copyright (c) 2000, 2001, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -38,13 +38,13 @@ class GetPeerHostClient extends Thread
SSLSocket s;
String server;
public GetPeerHostClient ()
public GetPeerHostClient (int serverPort)
{
try {
SSLSocketFactory factory = (SSLSocketFactory)SSLSocketFactory
.getDefault();
server = InetAddress.getLocalHost().getHostName();
s = (SSLSocket) factory.createSocket(server, 9999);
s = (SSLSocket) factory.createSocket(server, serverPort);
System.out.println("CLIENT: connected to the server- " + server);
} catch (Exception e) {
System.err.println("Unexpected exceptions: " + e);
......
/*
* Copyright (c) 2000, 2001, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -42,6 +42,7 @@ class GetPeerHostServer extends Thread
private String host;
ServerSocket ss;
boolean isHostIPAddr = false;
int serverPort = 0;
public GetPeerHostServer ()
{
......@@ -57,7 +58,8 @@ class GetPeerHostServer extends Thread
kmf.init(ks, passphrase);
ctx.init(kmf.getKeyManagers(), null, null);
ServerSocketFactory ssf = ctx.getServerSocketFactory();
ss = ssf.createServerSocket(9999);
ss = ssf.createServerSocket(serverPort);
serverPort = ss.getLocalPort();
}catch (Exception e) {
System.err.println("Unexpected exceptions: " + e);
e.printStackTrace();
......@@ -90,4 +92,8 @@ class GetPeerHostServer extends Thread
boolean getPassStatus () {
return isHostIPAddr;
}
int getServerPort() {
return serverPort;
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册