How do I configure a HostnameVerifier on an HttpsURLConnection?

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.
0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact