Skip to content

Commit 0eff492

Browse files
committed
8330278: Have SSLSocketTemplate.doClientSide use loopback address
Reviewed-by: ssahoo, rhalade
1 parent c6f611c commit 0eff492

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

test/jdk/javax/net/ssl/templates/SSLSocketTemplate.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -273,7 +273,7 @@ protected void doClientSide() throws Exception {
273273
configureClientSocket(sslSocket);
274274
InetAddress serverAddress = this.serverAddress;
275275
InetSocketAddress connectAddress = serverAddress == null
276-
? new InetSocketAddress("localhost", serverPort)
276+
? new InetSocketAddress(InetAddress.getLoopbackAddress(), serverPort)
277277
: new InetSocketAddress(serverAddress, serverPort);
278278
sslSocket.connect(connectAddress, 15000);
279279
} catch (IOException ioe) {

test/jdk/javax/net/ssl/templates/TLSBase.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
import javax.net.ssl.*;
2525
import java.io.*;
26+
import java.net.InetAddress;
2627
import java.net.InetSocketAddress;
2728
import java.security.KeyStore;
2829
import java.security.cert.PKIXBuilderParameters;
@@ -334,7 +335,7 @@ public SSLSocket connect() {
334335
sslContext = SSLContext.getInstance("TLS");
335336
sslContext.init(TLSBase.getKeyManager(km), TLSBase.getTrustManager(tm), null);
336337
sock = (SSLSocket)sslContext.getSocketFactory().createSocket();
337-
sock.connect(new InetSocketAddress("localhost", serverPort));
338+
sock.connect(new InetSocketAddress(InetAddress.getLoopbackAddress(), serverPort));
338339
System.err.println("Client connected using port " +
339340
sock.getLocalPort());
340341
name = "client(" + sock.toString() + ")";

0 commit comments

Comments
 (0)