1
我試圖加載一個頁面與Selenium進行測試,但我不斷收到此javax.net.ssl.SSLPeerUnverifiedException:對等身份驗證錯誤。現在我嘗試了許多不同的方法來允許它,但它根本行不通!javax.net.ssl.SSLPeerUnverifiedException:未通過使用Selenium和HtmlUnit進行身份驗證
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;
}
} ;
有沒有人有建議?