How do I configure a HostnameVerifier on an HttpsURLConnection?
Created Jul 27, 2001
Dwayne Schultz The solution:
connection.setHostnameVerifier(new HostnameVerifier()
{
public boolean verify(String urlHostname, String certHostname)
{
return ("www.badcert.com".equalsIgnoreCase(certHostname) &&
"xyz.badcert.com".equalsIgnoreCase(urlHostname))
}
});
Here I'm using a HostnameVerifier (in an anonymous class) to overlook a certificate name mismatch. In this case the vendor 'badcert.com' is using their 'www.badcert.com' on their 'xyz.badcert.com' server.