Merged in aslemmer-fix-debian-localhost-bind (pull request #423)

core: Bind client socket to getLocalHost explicitly, fixes #6
This commit is contained in:
Andras Slemmer 2016-11-01 10:04:28 +00:00
commit e5d210492b

View File

@ -230,6 +230,10 @@ class X509UtilitiesTest {
clientParams.endpointIdentificationAlgorithm = "HTTPS" // enable hostname checking
clientSocket.sslParameters = clientParams
clientSocket.useClientMode = true
// We need to specify this explicitly because by default the client binds to 'localhost' and we want it to bind
// to whatever <hostname> resolves to(as that's what the server binds to). In particular on Debian <hostname>
// resolves to 127.0.1.1 instead of the external address of the interface, so the ssl handshake fails.
clientSocket.bind(InetSocketAddress(InetAddress.getLocalHost(), 0))
val lock = Object()
var done = false
@ -281,4 +285,4 @@ class X509UtilitiesTest {
serverSocket.close()
assertTrue(done)
}
}
}