is there away to make chrome ignore the invalid certificate caused by using browsermob-proxy
i'm using google.com just for example reason, in the real case i need to provide credentials and login and the invalid certificate prevent me from continue.
please note here that the proxy is working perfectly and after i used all args to ignore the certificate issue https://i.sstatic.net/dG4Vl.png
import java.io.File;
import org.openqa.selenium.Proxy;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.remote.CapabilityType;
import org.testng.annotations.Test;
import net.lightbody.bmp.BrowserMobProxy;
import net.lightbody.bmp.BrowserMobProxyServer;
import net.lightbody.bmp.client.ClientUtil;
import net.lightbody.bmp.core.har.Har;
public class Proxytest4 {
WebDriver driver = null;
BrowserMobProxy proxy = null;
@Test
public void actionLaunchRegistrationPage() throws Exception {
System.setProperty("webdriver.chrome.driver", "/Users/path/chromedriver");
System.setProperty("webdriver.chrome.logfile", "/Users/path/hromedriver_issue.log");
proxy = new BrowserMobProxyServer();
proxy.setTrustAllServers(true);
proxy.start(0);
Proxy seleniumProxy = ClientUtil.createSeleniumProxy(proxy);
ChromeOptions options = new ChromeOptions();
options.addArguments("--proxy-server=" + seleniumProxy.getHttpProxy());
options.addArguments("--no-sandbox");
options.addArguments("--start-maximized");
options.addArguments("--disable-extensions");
options.addArguments("disable-gpu");
options.addArguments("window-size=1920,1080");
// options.setAcceptInsecureCerts(true);
options.addArguments("--allow-insecure-localhost");
options.addArguments("--ignore-certificate-errors");
options.addArguments("--allow-running-insecure-content");
// DesiredCapabilities cap = DesiredCapabilities.chrome();
// cap.acceptInsecureCerts();
// cap.setCapability (CapabilityType.ACCEPT_SSL_CERTS, true);
// cap.setCapability (CapabilityType.ACCEPT_INSECURE_CERTS, true);
// cap.setCapability(ChromeOptions.CAPABILITY, options);
// options.setAcceptInsecureCerts(true);
// options.merge(cap);
options.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
options.setCapability(CapabilityType.ACCEPT_INSECURE_CERTS, true);
// driver = new RemoteWebDriver(new URL("http://127.0.0.1:9515"), cap);
driver = new ChromeDriver(options);
// create a new HAR with the label "yahoo.com"
proxy.newHar("https://www.google.com/");
driver.get("https://www.google.com/");
// get the HAR data
Har har = proxy.getHar();
// Writing Har to file
har.getLog().toString();
har.writeTo(new File("/Users/path/HAR.txt"));
// driver.quit();
// browserStackLocal.stop();
proxy.stop();
}
}
The fix is as below:
1- download the browsermob-proxy certificate from the below link: https://github.com/lightbody/browsermob-proxy/blob/master/browsermob-core/src/main/resources/sslSupport/ca-certificate-rsa.cer
2- Open the Keychain Access utility in OS X.