Saturday, September 20, 2008

How to access secure website (https) in HTTPUNIT

If you are using httpunit to automate your website testing and your site is on secure domain (i.e. on https); httpunit would not be able to access your site unless you add below code in your tests(probably in setup() method)

//code to make test case run for HTTPS site com.sun.net.ssl.internal.www.protocol.https.HttpsURLConnectionOldImpl.setDefaultHostnameVerifier(new com.sun.net.ssl.HostnameVerifier()
{
public boolean verify(String urlHostname, String certHostname)
{
return true;
}
}
);

2 comments:

OliuDaria said...

This one is for jdk 1.4. Now replace for javax.net.sss.HttpsURLConnection

Vishnu Agrawal said...

Thanks OliuDaria !