question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Browsermob proxy does not intercept the request/response with headless chrome for secure (https) sites.

See original GitHub issue

Browsermob proxy does not intercept the request/response with headless chrome for secure (https://google.com) sites.

Its work fine with non-secure sites (http://cnn.com)

Tested with the following configuration

Browsermob proxy : 2.1.5 Chrome browser headless: 62.0.3202.94 (Official Build) (64-bit) ChromeDriver 2.33.506120

Here is a test case. Please provide any pointers on how to get this working or if it is bug that needs to be addressed.


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 io.netty.handler.codec.http.HttpRequest;
import io.netty.handler.codec.http.HttpResponse;
import net.lightbody.bmp.BrowserMobProxy;
import net.lightbody.bmp.BrowserMobProxyServer;
import net.lightbody.bmp.client.ClientUtil;
import net.lightbody.bmp.filters.RequestFilter;
import net.lightbody.bmp.filters.ResponseFilter;
import net.lightbody.bmp.util.HttpMessageContents;
import net.lightbody.bmp.util.HttpMessageInfo;

public class HeadlessChromeWithBmpTest {
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		try {
			System.setProperty("webdriver.chrome.logfile", "c:\\mystuff\\chromedriver_issue.log");
			System.setProperty("webdriver.chrome.driver",
					"C:/mystuff/qb_collector/drivers/chrome/chromedriver_233.exe");

			BrowserMobProxy proxy = new BrowserMobProxyServer();
			proxy.start(0);
			addRequestResponseFilters(proxy);
			proxy.newHar("test-har");
			Proxy seleniumProxy = ClientUtil.createSeleniumProxy(proxy);

			ChromeOptions options = new ChromeOptions();
			options.setCapability(CapabilityType.PROXY, seleniumProxy);
			options.setAcceptInsecureCerts(true);
			options.addArguments("--allow-insecure-localhost");
			// options.addArguments("--headless");
			// options.addArguments("--proxy-server=localhost:" +
			// proxy.getPort());
			// options.addArguments("--proxy-server=localhost:" + "8888");
			options.setHeadless(true);
			WebDriver driver = new ChromeDriver(options);
			driver.get("https://www.google.com");
			

			System.out.println("Done");
			driver.close();
			Thread.sleep(5000);
			System.out.println("Har Entries :" + proxy.getHar().getLog().getEntries().size());
			proxy.stop();

		} catch (Exception e) {
			System.out.println("!!! Exception:");
			System.out.println(e);
		}
	}

	public static void addRequestResponseFilters(BrowserMobProxy proxy) {

		// request filter
		proxy.addRequestFilter(new RequestFilter() {
			@Override
			public HttpResponse filterRequest(HttpRequest request, HttpMessageContents contents,
					HttpMessageInfo messageInfo) {

				System.out.println("Intercepting request for URL :" + messageInfo.getUrl());
				return null;
			}
		});
		// response filter
		proxy.addResponseFilter(new ResponseFilter() {
			@Override
			public void filterResponse(HttpResponse response, HttpMessageContents contents,
					HttpMessageInfo messageInfo) {

				System.out.println("intercepting response for url :" + messageInfo.getOriginalUrl());
			}
		});
	}
}

`

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5

github_iconTop GitHub Comments

4reactions
medigacommented, Nov 21, 2017

I was able to get this working by importing browsermob’s ca-certificate-rsa.cer into Chrome browser

0reactions
nanshummtcommented, Sep 8, 2018

@mediga How to import browsermob’s ca-certificate-rsa.cer into Chrome browser

Read more comments on GitHub >

github_iconTop Results From Across the Web

Login with Selenium + Chrome driver + Browsermob Proxy ...
I have the code below to initialise a setup of Selenium + Chrome driver + Browsermob Proxy to login to a certain website....
Read more >
Web Test Tools - SoftwareQATest.com
Listing of 500 web test tools and management tools - load testing, mobile testing, page speed testing, link checking, html validation, ...
Read more >
Interface BrowserMobProxy - javadoc.io
Completely disables MITM for this proxy server. The proxy will no longer intercept HTTPS requests, but they will still be pass-through proxied. This...
Read more >
August 2019 - OUseful.Info, the blog…
What that in turn means is that when I am hacking around with the document in the notebook UI I can create documents...
Read more >
Selenium Support - Medium
Moreover, many components has memory/resource leaks that are not… ... Quote from https://github.com/lightbody/browsermob-proxy#rest-api.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found