[Python] ssl ,urllib3,requests .exceptions.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED]...

Discussão em 'Python' iniciado por Stack, Abril 27, 2025.

  1. Stack

    Stack Membro Participativo

    I'm developing an application that collects information from YouTube via the YouTube APIv3. I'm using yapi package from github. I was working in Python2.7 and it worked fine.

    But when I upgraded to Python 3.3 it suddenly gave me a certificate error.

    Input


    import yapi
    Youtube = yapi.YoutubeAPI('API KEY')
    Results = Youtube.general_search('keyword', max_results=10)
    print(Results)

    Output


    Traceback (most recent call last):
    File "C:\Python33\lib\site-packages\urllib3\connectionpool.py", line 600, in urlopen
    chunked=chunked)
    File "C:\Python33\lib\site-packages\urllib3\connectionpool.py", line 345, in _make_request
    self._validate_conn(conn)
    File "C:\Python33\lib\site-packages\urllib3\connectionpool.py", line 844, in _validate_conn
    conn.connect()
    File "C:\Python33\lib\site-packages\urllib3\connection.py", line 326, in connect
    ssl_context=context)
    File "C:\Python33\lib\site-packages\urllib3\util\ssl_.py", line 325, in ssl_wrap_socket
    return context.wrap_socket(sock, server_hostname=server_hostname)
    File "C:\Python33\lib\ssl.py", line 246, in wrap_socket
    _context=self)
    File "C:\Python33\lib\ssl.py", line 350, in __init__
    raise x
    File "C:\Python33\lib\ssl.py", line 346, in __init__
    self.do_handshake()
    File "C:\Python33\lib\ssl.py", line 553, in do_handshake
    self._sslobj.do_handshake()
    ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:548)

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
    File "C:\Python33\lib\site-packages\requests\adapters.py", line 440, in send
    timeout=timeout
    File "C:\Python33\lib\site-packages\urllib3\connectionpool.py", line 630, in urlopen
    raise SSLError(e)
    urllib3.exceptions.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:548)

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
    File "C:/Users/a227855/PycharmProjects/Youtube/Search.py", line 3, in <module>
    Results = Youtube.general_search('keyword', max_results=10)
    File "C:\Python33\lib\site-packages\yapi.py", line 36, in general_search
    objects = manager.api_request(api_url, params)
    File "C:\Python33\lib\site-packages\manager.py", line 47, in api_request
    con = requests.get(req_url)
    File "C:\Python33\lib\site-packages\requests\api.py", line 72, in get
    return request('get', url, params=params, **kwargs)
    File "C:\Python33\lib\site-packages\requests\api.py", line 58, in request
    return session.request(method=method, url=url, **kwargs)
    File "C:\Python33\lib\site-packages\requests\sessions.py", line 502, in request
    resp = self.send(prep, **send_kwargs)
    File "C:\Python33\lib\site-packages\requests\sessions.py", line 612, in send
    r = adapter.send(request, **kwargs)
    File "C:\Python33\lib\site-packages\requests\adapters.py", line 514, in send
    raise SSLError(e, request=request)
    requests.exceptions.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:548)

    Process finished with exit code 1


    I had to change to Python 3.4 to try support other functions that I was using that only supported 3 and up.

    Continue reading...

Compartilhe esta Página