selenium-wire
selenium-wire copied to clipboard
getting an error 502 bad gateway
Hey,
I'm using selenium-wire, when I open my website, I'm getting
TlsProtocolException('Cannot establish TLS with xxxxxxx (sni: xxxxxx): TlsException("SSL handshake error: Error([(\'SSL routines\', \'\', \'unsafe legacy renegotiation disabled\')])")')
..
when I open the same website without selenium-wire, just with selenium, it works fine..
the website url is https and I have valid certificate and connection is secure.
from seleniumwire import webdriver
chrome_options = Options()
chrome_options.add_experimental_option("detach", True)
chrome_options.add_argument("--start-maximized")
chrome_options.add_argument('--auto-open-devtools-for-tabs')
chrome_options.add_argument('--log-level=2')
chrome_options.add_experimental_option('excludeSwitches', ['enable-logging'])
chrome_options.add_argument("window-size=1280,720")
chrome_options.add_argument('--disable-dev-shm-usage')
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument("--disable-extensions")
chrome_options.add_argument("--disable-setuid-sandbox")
chrome_options.add_argument("--ignore_ssl")
chrome_options.add_argument("--dns-prefetch-disable")
chrome_options.add_argument('ignore-certificate-errors')
capabilities = DesiredCapabilities.CHROME
capabilities["goog:loggingPrefs"] = {"performance": "ALL",'browser':'ALL','server':'ALL'} # chromedriver 75+
capabilities['extendedDebugging'] = True
capabilities['acceptSslCerts'] = True
capabilities['acceptInsecureCerts'] = True
capabilities['PageLoadStrategy'] = None
selenium_options = {
'verify_ssl': False,
'connection_timeout': None,
'backend': 'mitmproxy'
}
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=chrome_options,desired_capabilities=capabilities,
seleniumwire_options=selenium_options)
driver.get(os.environ['URL'])
Thanks for raising this. It looks like the error is related to OpenSSL which selenium wire uses behind the scenes.
This SO suggests a workaround. Perhaps you could give that a try?
Yes, it solved my issue. thank you for saving my time!
@wkeeling
Hey, I restarted my pc and still have the same issue..
when I run
pip install cryptography
it shows me
Requirement already satisfied: cryptography in ./.venv/lib/python3.9/site-packages (38.0.2)
Requirement already satisfied: cffi>=1.12 in ./.venv/lib/python3.9/site-packages (from cryptography) (1.15.1)
Requirement already satisfied: pycparser in ./.venv/lib/python3.9/site-packages (from cffi>=1.12->cryptography) (2.21)
WARNING: There was an error checking the latest version of pip.
I have openssl latest version.. what I can do?
my chrome options
options = ChromeOptions()
options.add_argument('--no-sandbox')
options.add_argument('--single-process')
options.add_argument('--disable-dev-shm-usage')
options.add_argument("--start-maximized")
options.add_argument('--auto-open-devtools-for-tabs')
options.add_argument('--log-level=2')
options.add_argument('--disable-features=IsolateOrigins,site-per-process')
options.add_argument("--ignore_ssl")
options.add_argument('--ignore-ssl-errors')
options.add_argument('--ignore-certificate-errors')
options.add_argument('--allow-insecure-localhost')
self._driver = webdriver.Chrome(options)
I have the same problem use selenium-wire on my Windows. how to sovle it?
And I have the same problem. I'm using proxy and trying to access blocked site https://news.google.com/home
Adding the argument below when initiating a driver works for me. I'm using seleniumwire-5.1.0 and firefox-114 in docker. I also downgraded cryptography to 36.0.2 and pyOpenSSL to 22.0.0.
capabilities={"acceptInsecureCerts": True}
Source https://developer.mozilla.org/en-US/docs/Web/WebDriver/Capabilities/acceptInsecureCerts