From 489e269b901d1a951fd492be552b76308a3e86c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Se=C3=A1n=20Coffey?= Date: Fri, 3 May 2024 09:18:38 +0000 Subject: [PATCH] Initial commit --- test/jdk/javax/net/ssl/templates/SSLSocketTemplate.java | 4 ++-- test/jdk/javax/net/ssl/templates/TLSBase.java | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/test/jdk/javax/net/ssl/templates/SSLSocketTemplate.java b/test/jdk/javax/net/ssl/templates/SSLSocketTemplate.java index 3515ca9c2fff1..b67f897830473 100644 --- a/test/jdk/javax/net/ssl/templates/SSLSocketTemplate.java +++ b/test/jdk/javax/net/ssl/templates/SSLSocketTemplate.java @@ -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 @@ protected void doClientSide() throws Exception { 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) { diff --git a/test/jdk/javax/net/ssl/templates/TLSBase.java b/test/jdk/javax/net/ssl/templates/TLSBase.java index 414e7e106b327..812aea09fea11 100644 --- a/test/jdk/javax/net/ssl/templates/TLSBase.java +++ b/test/jdk/javax/net/ssl/templates/TLSBase.java @@ -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 @@ public SSLSocket connect() { 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() + ")";