wkeeling / selenium-wire

Extends Selenium's Python bindings to give you the ability to inspect requests made by the browser.
MIT License
1.9k stars 254 forks source link

Documentation: dependency on SSL library #188

Closed axgdev closed 3 years ago

axgdev commented 3 years ago

First of all, thank you for the awesome library!

This is might very obvious but selenium-wire won't work properly with HTTPS sites without a SSL library installed in the system.

I was using Alpine linux in docker and got this error when trying to load google.com: Message: Reached error page: about:neterror?e=nssFailure2&u=https%3A//google.com/&c=UTF-8&d=The%20connection%20to%20google.com%20was%20interrupted%20while%20the%20page%20was%20loading.

The python Alpine linux docker image does not come with a SSL library installed. So to use selenium-wire you have to install a SSL library such as OpenSSL. Example: apk add openssl

Apparently selenium-wire does not seem to work with libressl, at least in Alpine Linux.

wkeeling commented 3 years ago

Thanks for raising this. The documentation did have a step for installing OpenSSL, but it was recently removed in version 3.0.0 as I thought OpenSSL was installed on most systems by default - but it seems that's not the case. I'll add that step back in.

Out of curiosity, what issue did you encounter when you tried to use LibreSSL?

wkeeling commented 3 years ago

The documentation has been updated to mention OpenSSL in v3.0.3 of Selenium Wire.

axgdev commented 3 years ago

@wkeeling As you said, OpenSSL is probably installed in most systems by default, so my case is probably very rare. When I used libressl, I got the same error as not having a SSL library at all. If you want to reproduce it, here is what I did.

  1. docker run -d -p 4444:4444 --name selenium_firefox selenium/standalone-firefox:3.141.59-20201119, this runs a container with ip address 172.17.0.2 in case no other container was running in the background
  2. docker run -it python:3.8-alpine sh this runs a container with ip address 172.17.0.3 in case only the firefox selenium container was running in the background
  3. apk add libressl
  4. pip install selenium
  5. pip install selenium-wire
  6. Then I executed the script below:
    
    from seleniumwire import webdriver
    from selenium.webdriver import FirefoxProfile
    from selenium.webdriver.common.desired_capabilities import DesiredCapabilities

firefoxDockerAddress = '172.17.0.2' firefoxDockerPort = '4444' dockerProxyAddress = '172.17.0.3'

driver = webdriver.Remote("http://{0}:{1}/wd/hub".format(firefoxDockerAddress, firefoxDockerPort), desired_capabilities=DesiredCapabilities.FIREFOX, seleniumwire_options={'addr': dockerProxyAddress, })

driver.get('https://google.com')

for r in driver.requests: print(r.path, r)

driver.quit()



And I got: Message: `Reached error page: about:neterror?e=nssFailure2&u=https%3A//google.com/&c=UTF-8&d=The%20connection%20to%20google.com%20was%20interrupted%20while%20the%20page%20was%20loading.`

If I replace the step 3 with `apk add openssl` then everything is fine.