miyakogi / pyppeteer

Headless chrome/chromium automation library (unofficial port of puppeteer)
Other
3.56k stars 372 forks source link

SSLCertVerificationError #219

Closed aborruso closed 5 years ago

aborruso commented 5 years ago

Hi, whent I run pyppeteer-install, I have SSL error. How to solve it?

Thank you

[W:pyppeteer.chromium_downloader] start chromium download.
Download may take a few minutes.
Traceback (most recent call last):
  File "/home/aborruso/.local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 603, in urlopen
    chunked=chunked)
  File "/home/aborruso/.local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 344, in _make_request
    self._validate_conn(conn)
  File "/home/aborruso/.local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 843, in _validate_conn
    conn.connect()
  File "/home/aborruso/.local/lib/python3.7/site-packages/urllib3/connection.py", line 350, in connect
    ssl_context=context)
  File "/home/aborruso/.local/lib/python3.7/site-packages/urllib3/util/ssl_.py", line 355, in ssl_wrap_socket
    return context.wrap_socket(sock, server_hostname=server_hostname)
  File "/usr/lib/python3.7/ssl.py", line 412, in wrap_socket
    session=session
  File "/usr/lib/python3.7/ssl.py", line 853, in _create
    self.do_handshake()
  File "/usr/lib/python3.7/ssl.py", line 1117, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1056)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/aborruso/.local/bin/pyppeteer-install", line 11, in <module>
    load_entry_point('pyppeteer==0.0.25', 'console_scripts', 'pyppeteer-install')()
  File "/home/aborruso/.local/lib/python3.7/site-packages/pyppeteer/command.py", line 14, in install
    download_chromium()
  File "/home/aborruso/.local/lib/python3.7/site-packages/pyppeteer/chromium_downloader.py", line 136, in download_chromium
    extract_zip(download_zip(get_url()), DOWNLOADS_FOLDER / REVISION)
  File "/home/aborruso/.local/lib/python3.7/site-packages/pyppeteer/chromium_downloader.py", line 78, in download_zip
    data = http.request('GET', url, preload_content=False)
  File "/home/aborruso/.local/lib/python3.7/site-packages/urllib3/request.py", line 68, in request
    **urlopen_kw)
  File "/home/aborruso/.local/lib/python3.7/site-packages/urllib3/request.py", line 89, in request_encode_url
    return self.urlopen(method, url, **extra_kw)
  File "/home/aborruso/.local/lib/python3.7/site-packages/urllib3/poolmanager.py", line 326, in urlopen
    response = conn.urlopen(method, u.request_uri, **kw)
  File "/home/aborruso/.local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 670, in urlopen
    **response_kw)
  File "/home/aborruso/.local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 670, in urlopen
    **response_kw)
  File "/home/aborruso/.local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 670, in urlopen
    **response_kw)
  File "/home/aborruso/.local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 641, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/home/aborruso/.local/lib/python3.7/site-packages/urllib3/util/retry.py", line 399, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='storage.googleapis.com', port=443): Max retries exceeded with url: /chromium-browser-snapshots/Linux_x64/575458/chrome-linux.zip (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1056)')))
miyakogi commented 5 years ago

This is a problem of urllib3 (1.25). Workaround is to use older version of it:

pip install -U "urllib3<1.25"
aborruso commented 5 years ago

Thank you @miyakogi

milg15 commented 4 years ago

Thanks the solution worked!!! I've been running into this problem <3 @miyakogi

kiwi0fruit commented 4 years ago

I think it's a bad idea to use unsecure download. I recommend to try:

pip install pyppdf

then in the code first use:

import pyppdf.patch_pyppeteer

that would apply the patch and nothing more is required to do (see this for details).

leadscloud commented 4 years ago

This is a problem of urllib3 (1.25). Workaround is to use older version of it:

pip install -U "urllib3<1.25"

this works for me.

but

ERROR: pyppeteer2 0.2.2 has requirement urllib3<2.0.0,>=1.25.8, but you'll have urllib3 1.24.3 which is incompatible.