我正在尝试使用 Selenium 加载页面进行测试,但我不断收到此 javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated 错误。现在我尝试了许多不同的方法来允许它,但它根本行不通!
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;
}
} ;
有人有建议吗?