How do I configure a HostnameVerifier on an HttpsURLConnection?
Location: http://www.jguru.com/faq/view.jsp?EID=463751 Created: Jul 27, 2001 Author: Dwayne Schultz (http://www.jguru.com/guru/viewbio.jsp?EID=463738) Question originally posed by John Zukowski PREMIUM (http://www.jguru.com/guru/viewbio.jsp?EID=7 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.