8330278: Have SSLSocketTemplate.doClientSide use loopback address
Reviewed-by: ssahoo, rhalade
This commit is contained in:
parent
c6f611cfe0
commit
0eff492e41
test/jdk/javax/net/ssl/templates
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* 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) {
|
||||
|
@ -23,6 +23,7 @@
|
||||
|
||||
import javax.net.ssl.*;
|
||||
import java.io.*;
|
||||
import java.net.InetAddress;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.security.KeyStore;
|
||||
import java.security.cert.PKIXBuilderParameters;
|
||||
@ -334,7 +335,7 @@ abstract public class TLSBase {
|
||||
sslContext = SSLContext.getInstance("TLS");
|
||||
sslContext.init(TLSBase.getKeyManager(km), TLSBase.getTrustManager(tm), null);
|
||||
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() + ")";
|
||||
|
Loading…
x
Reference in New Issue
Block a user