seleniumbase / SeleniumBase

📊 Python's all-in-one framework for web crawling, scraping, testing, and reporting. Supports pytest. UC Mode provides stealth. Includes many tools.
https://seleniumbase.io
MIT License
5.16k stars 958 forks source link

SSL Errors on MacOS when downloading chromedriver #2724

Closed Dylgod closed 5 months ago

Dylgod commented 5 months ago

Running Sonoma 14.4.1, reset to factory defaults, with python 3.12.2

The error: ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1000)

Running certifi.where() yields the cacert.pem <redacted for length>/lib/python3.12/site-packages/certifi/cacert.pem which (seems to) have valid certs upon visual inspection.

When I build the app bundle with Py2app, and then run the executable inside

I get this traceback ```python Warning: uc_driver not found. Getting it now: *** chromedriver to download = 124.0.6367.91 (Latest Stable) Traceback (most recent call last): File "urllib/request.pyc", line 1344, in do_open File "http/client.pyc", line 1331, in request File "http/client.pyc", line 1377, in _send_request File "http/client.pyc", line 1326, in endheaders File "http/client.pyc", line 1085, in _send_output File "http/client.pyc", line 1029, in send File "http/client.pyc", line 1472, in connect File "ssl.pyc", line 455, in wrap_socket File "ssl.pyc", line 1042, in _create File "ssl.pyc", line 1320, in do_handshake ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1000) During handling of the above exception, another exception occurred: Traceback (most recent call last): File "seleniumbase/core/browser_launcher.pyc", line 3540, in get_local_driver File "seleniumbase/undetected/__init__.pyc", line 130, in __init__ File "seleniumbase/undetected/patcher.pyc", line 108, in auto File "seleniumbase/undetected/patcher.pyc", line 126, in fetch_release_number File "urllib/request.pyc", line 215, in urlopen File "urllib/request.pyc", line 515, in open File "urllib/request.pyc", line 532, in _open File "urllib/request.pyc", line 492, in _call_chain File "urllib/request.pyc", line 1392, in https_open File "urllib/request.pyc", line 1347, in do_open urllib.error.URLError: During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/Users/dylan/PycharmProjects/shy_drivers/apptest/dist/mac_shytest.app/Contents/Resources/__boot__.py", line 161, in File "/Users/dylan/PycharmProjects/shy_drivers/apptest/dist/mac_shytest.app/Contents/Resources/__boot__.py", line 84, in _run File "/Users/dylan/PycharmProjects/shy_drivers/apptest/dist/mac_shytest.app/Contents/Resources/mac_shytest.py", line 5, in File "seleniumbase/plugins/driver_manager.pyc", line 516, in Driver File "seleniumbase/core/browser_launcher.pyc", line 1632, in get_driver File "seleniumbase/core/browser_launcher.pyc", line 3552, in get_local_driver TypeError: argument of type 'SSLCertVerificationError' is not iterable ```

I noticed it error'd after running undetected/patcher, so I created a patcher object and ran:

firsttry = Patcher(version_main=0, force=False, executable_path=None) 
firsttry.auto()
which yields this traceback ```python Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/urllib/request.py", line 1344, in do_open h.request(req.get_method(), req.selector, req.data, headers, File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/http/client.py", line 1331, in request self._send_request(method, url, body, headers, encode_chunked) File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/http/client.py", line 1377, in _send_request self.endheaders(body, encode_chunked=encode_chunked) File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/http/client.py", line 1326, in endheaders self._send_output(message_body, encode_chunked=encode_chunked) File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/http/client.py", line 1085, in _send_output self.send(msg) File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/http/client.py", line 1029, in send self.connect() File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/http/client.py", line 1472, in connect self.sock = self._context.wrap_socket(self.sock, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/ssl.py", line 455, in wrap_socket return self.sslsocket_class._create( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/ssl.py", line 1042, in _create self.do_handshake() File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/ssl.py", line 1320, in do_handshake self._sslobj.do_handshake() ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1000) During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/Users/dylan/PycharmProjects/shy_drivers/apptest/test1.py", line 306, in firsttry.auto() File "/Users/dylan/PycharmProjects/shy_drivers/apptest/test1.py", line 108, in auto release = self.fetch_release_number() ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/dylan/PycharmProjects/shy_drivers/apptest/test1.py", line 126, in fetch_release_number return urlopen(self.url_repo + path).read().decode() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/urllib/request.py", line 215, in urlopen return opener.open(url, data, timeout) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/urllib/request.py", line 515, in open response = self._open(req, data) ^^^^^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/urllib/request.py", line 532, in _open result = self._call_chain(self.handle_open, protocol, protocol + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/urllib/request.py", line 492, in _call_chain result = func(*args) ^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/urllib/request.py", line 1392, in https_open return self.do_open(http.client.HTTPSConnection, req, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/urllib/request.py", line 1347, in do_open raise URLError(err) urllib.error.URLError: Exception ignored in: Traceback (most recent call last): File "/Users/dylan/PycharmProjects/shy_drivers/apptest/test1.py", line 283, in __del__ AttributeError: 'NoneType' object has no attribute 'monotonic' ```
mdmintz commented 5 months ago

That's an external issue with py2app: https://github.com/ronaldoussoren/py2app/issues/184 (not SeleniumBase).

You could try installing https://pypi.org/project/pip-system-certs/ to get around it.