Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trusting all Servers and bypassing Basic Authentication #86

Closed
ghost opened this issue Aug 7, 2018 · 2 comments
Closed

Trusting all Servers and bypassing Basic Authentication #86

ghost opened this issue Aug 7, 2018 · 2 comments

Comments

@ghost
Copy link

ghost commented Aug 7, 2018

I am using Windows + Python + Selenium (latest) + Browsermob-proxy-py + Chrome, FF, IE.

After following the installation instructions and the example provided by the documentation, my code looks like this:

@pytest.fixture(scope="session", autouse=True)
def selenium_proxy():
    proxy = Client("localhost:9090")
    proxy.trustAllServers(True)
    proxy.basic_authentication("", HTACCESS_USERNAME, HTACCESS_PASSWORD)

    yield proxy.selenium_proxy()

    proxy.close()
# I defined this method in browsermob-proxy-py/client.py 
def trustAllServers(self, value):
    r = requests.post(url='%s/proxy' % (self.host),
                      data=json.dumps({'trustAllServers': value}),
                      headers={'content-type': 'application/json'})
    return r.status_code

I am running the browsermob proxy standalone version like this:
java -jar browsermob-dist-2.1.4.jar --port 9090

I did this by following the official browsermob-proxy documentation, which can be found here

Printing the response code for both methods: trustAllServers (Returns 200) and basic_authentication (Returns 404) <- Why?

The main issue is: when I try to load an URL with selenium the browser will say that the page cannot be loaded. If I run my tests with internet explorer, some weird unwanted windows configurations will take place and I will have to manually deactivate the LAN Proxy configuration in the Internet Options in order to recover my internet connection.

The console logs informs two main Problems:

...
Caused by: javax.net.ssl.SSLHandshakeException: General SSLEngine problem
...

and

...
Caused by: java.security.cert.CertificateException: No subject alternative DNS name matching <host> found.
...

I've been reading for hours and the solution I always end up finding is trusting all servers, which "I am already doing" with the trustAllServers method I defined. Maybe I am doing something wrong?

Edit: I am trying to do something like this
https://www.softensity.com/browsermob-proxy-qa/

@ghost
Copy link
Author

ghost commented Aug 13, 2018

Installing this Certificate to Trusted Root Certification Authorities on Windows solved most of my issues.

Now the remaining issue is handling the alert dialog window of any domain with the basic_authentication method. Giving "*" as domain-parameter returns 200 response status code. However, the alert window appears anyway.

@ghost
Copy link
Author

ghost commented Aug 13, 2018

I wasn't able to match all domains with a generic expression (empty string or *). But you can match all subdomains by just giving "domain.com". This solves my issue for now.

@ghost ghost closed this as completed Aug 13, 2018
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants