Skip to content
Snippets Groups Projects
Commit f4489554 authored by Goetz Lindenmaier's avatar Goetz Lindenmaier
Browse files

8330278: Have SSLSocketTemplate.doClientSide use loopback address

Backport-of: 0eff492e4107abc5624f0c3445877bf38629a980
parent c41236b7
No related branches found
No related tags found
No related merge requests found
/*
* Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2024, 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
......@@ -273,7 +273,7 @@ public class SSLSocketTemplate extends SSLContextTemplate {
configureClientSocket(sslSocket);
InetAddress serverAddress = this.serverAddress;
InetSocketAddress connectAddress = serverAddress == null
? new InetSocketAddress("localhost", serverPort)
? new InetSocketAddress(InetAddress.getLoopbackAddress(), serverPort)
: new InetSocketAddress(serverAddress, serverPort);
sslSocket.connect(connectAddress, 15000);
} catch (IOException ioe) {
......
......@@ -31,6 +31,7 @@ import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.util.Arrays;
import java.util.concurrent.ConcurrentHashMap;
......@@ -222,7 +223,7 @@ abstract public class TLSBase {
try {
sslContext = SSLContext.getDefault();
sock = (SSLSocket)sslContext.getSocketFactory().createSocket();
sock.connect(new InetSocketAddress("localhost", serverPort));
sock.connect(new InetSocketAddress(InetAddress.getLoopbackAddress(), serverPort));
System.err.println("Client connected using port " +
sock.getLocalPort());
name = "client(" + sock.toString() + ")";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment