Reputation: 1296
I am attempting to load a page with Selenium for testing, but I keep getting this javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated error. Now I have tried MANY different ways of allowing it, but it simply will not work!
WebDriver driver = new HtmlUnitDriver(){
protected WebClient modifyWebClient(WebClient client){
try {
client = new WebClient(BrowserVersion.FIREFOX_3_6);
client.setUseInsecureSSL(true);
client.setUseInsecureSSL(true);
client.setThrowExceptionOnScriptError( false );
client.setPrintContentOnFailingStatusCode( true );
client.setThrowExceptionOnFailingStatusCode( true );
client.setCssEnabled( true );
client.setJavaScriptEnabled( true );
XTrustProvider.install(); // Allow all certs
SSLUtilities.trustAllHostnames();// to turn off the default hostname verification on HTTPS connection;
SSLUtilities.trustAllHttpsCertificates();// to turn off the default certificate validation on HTTPS
} catch (GeneralSecurityException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return client;
}
} ;
Does anyone have suggestions?
Upvotes: 1
Views: 2725
Reputation: 1296
I have figured it out. It seems to be a bug in HtmlUnit with the currently available 2.9 version released in 2011. I built it from source and now it works!
Upvotes: 1