SSLHandshakeException: handshake_failure, logging proper reason for handshake failure
posted 1 year ago
I am using HttpURLConnection to connect to a server. I was running into a situation where the handshake failure happened due to the mismatching protocols. Server supported TLS where as client was apparently using SSLv3. When I forced the client to use TLS (as shown in the code below - line#2), the connection succeeded returning expected results.
However, I would like to log the reason for failure correctly if this situation was to happen again.
Is there a way where programmatically I can get the server's lowest and client's highest supported version for logging. Also it would be great if someone could point a way to get the reason for handshake failure in the code for logging.