mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-17 10:25:15 +00:00
PkiAuthenticationTests & SslIntegrationTests should properly handle ipv6 addresses
Original commit: elastic/x-pack-elasticsearch@b11d90e584
This commit is contained in:
parent
f977632a17
commit
133d70bc6a
@ -32,6 +32,7 @@ import javax.net.ssl.KeyManagerFactory;
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.TrustManagerFactory;
|
||||
import java.io.InputStream;
|
||||
import java.net.Inet6Address;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
@ -158,7 +159,13 @@ public class PkiAuthenticationTests extends SecurityIntegTestCase {
|
||||
private String getNodeUrl() {
|
||||
TransportAddress transportAddress = randomFrom(internalCluster().getInstance(HttpServerTransport.class)
|
||||
.boundAddress().boundAddresses());
|
||||
final InetSocketAddress inetAddress = transportAddress.address();
|
||||
return String.format(Locale.ROOT, "https://%s:%s/", inetAddress.getHostString(), inetAddress.getPort());
|
||||
final InetSocketAddress inetSocketAddress = transportAddress.address();
|
||||
final String host;
|
||||
if (inetSocketAddress.getAddress() instanceof Inet6Address) {
|
||||
host = "[" + inetSocketAddress.getAddress().getHostAddress() + "]";
|
||||
} else {
|
||||
host = inetSocketAddress.getAddress().getHostAddress();
|
||||
}
|
||||
return String.format(Locale.ROOT, "https://%s:%s/", host, inetSocketAddress.getPort());
|
||||
}
|
||||
}
|
||||
|
@ -32,6 +32,7 @@ import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.SSLHandshakeException;
|
||||
import javax.net.ssl.TrustManagerFactory;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.Inet6Address;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.KeyStore;
|
||||
@ -132,7 +133,13 @@ public class SslIntegrationTests extends SecurityIntegTestCase {
|
||||
private String getNodeUrl() {
|
||||
TransportAddress transportAddress =
|
||||
randomFrom(internalCluster().getInstance(HttpServerTransport.class).boundAddress().boundAddresses());
|
||||
final InetSocketAddress inetAddress = transportAddress.address();
|
||||
return String.format(Locale.ROOT, "https://%s:%s/", inetAddress.getHostString(), inetAddress.getPort());
|
||||
final InetSocketAddress inetSocketAddress = transportAddress.address();
|
||||
final String host;
|
||||
if (inetSocketAddress.getAddress() instanceof Inet6Address) {
|
||||
host = "[" + inetSocketAddress.getAddress().getHostAddress() + "]";
|
||||
} else {
|
||||
host = inetSocketAddress.getAddress().getHostAddress();
|
||||
}
|
||||
return String.format(Locale.ROOT, "https://%s:%s/", host, inetSocketAddress.getPort());
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user