Under what circumstances would one use a HostnameVerifier
over a TrustManager
in Java? Is one recommended over the other? Looking at the Java docs (Interface HostnameVerifier and Interface TrustManager), I can't tell when its best to use either (though the TrustManager
seems more versatile).
In the past, I have always used a custom TrustManager
. However, I noticed Heartbleed exploit in java uses both (but I don't think its correct).
EDIT: when using HostnameVerifier
, are the other customary X509 checks performed, like path building and expiration and revocation (if configured)? I think I am essentially asking if HostnameVerifier
supplements the other checks (rather than replacing them).
For example, suppose a dev server is at dev.example.com
and its signed by an internal CA. There's one DNS name in dev.example.com
's certificate, and its dev.example.com
. Further, suppose I connect to it as 192.168.1.10
. Could I use a HostnameVerifier
to allow both dev.example.com
and 192.168.1.10
? In this scenario, is the additional name allowed and are the other customary X509 checks are performed?
TrustManager
cannot be used to override a hostname mismatch incheckServerTrusted
? – Boschbok