I am experimenting right now with SSL configs using KeyManager and TrustManager, everything seems clear to me except the HostNameVerifier part.
I have read the followings:
https://docs.oracle.com/javase/7/docs/api/javax/net/ssl/HostnameVerifier.html
https://lightbend.github.io/ssl-config/HostnameVerification.html
So basically it comes in effect when the requested URL and the URL in the cert are mismatch.
What is the best practice to handle this?
new HostnameVerifier() {
@Override
public boolean verify(String hostname, SSLSession session) {
// some code
}
};
From security(like man in the middle attack) point of view I think it must return false all the time.But in this case what is the purpose of this whole thing?
However surfing on the internet most of the time I come accross solutions that return a raw 'true' (without any work on the arguments).
So its confusing to me when,why and how should I use it.
Could you elaborate it please?