fix smoke-test-plugins-ssl to work when ::1 does not resolve at all.

My previous change only fixed it when it resolves to something different than localhost.
But in some cases, it does not resolve at all, we must specify the IP.

Original commit: elastic/x-pack-elasticsearch@547eb4c42f
This commit is contained in:
Robert Muir 2015-12-15 01:04:37 -05:00
parent e574552288
commit d85bb59d57
1 changed files with 8 additions and 2 deletions

View File

@ -20,11 +20,17 @@ task createKey(type: LoggedExec) {
}
String subjectAlternateNames = 'san=dns:localhost,ip:127.0.0.1'
// some machines have a different name for ipv6 loopback,
// at least on ubuntu its ip6-localhost
// at least on ubuntu its ip6-localhost. other machines, like windows,
// won't resolve it back to any hostname at all. Try to setup ipv6 to
// work in all cases.
try {
String localhost6 = InetAddress.getByName("::1").getCanonicalHostName()
if (!localhost6.equals("localhost")) {
subjectAlternateNames += ",dns:" + localhost6
if (localhost6.startsWith("0")) {
subjectAlternateNames += ",ip:" + localhost6
} else {
subjectAlternateNames += ",dns:" + localhost6
}
}
} catch (UnknownHostException ok) {
// e.g. no ipv6 support