[Python] Why does calling curl solve my SSL issues in Python on Windows

Discussão em 'Python' iniciado por Stack, Fevereiro 22, 2025.

  1. Stack

    Stack Membro Participativo

    This is a pretty bizarre issue. I have created a fresh Windows 11 VM using VMware Fusion on Mac. I installed VMware Tools and Python on it

    winget install -e --id Python.Python.3.11


    I start python from the Powershell terminal and try to connect to Google for testing:

    >>> import urllib.request
    >>> urllib.request.urlopen("https://www.google.com").status


    The result is an error:

    urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1006)>


    Now I figured out that to fix the error I need to exit python and type into the terminal

    curl https://www.google.com


    This will generate for a very short moment a message in the terminal:

    [​IMG]

    Afterwards my SSL issues are resolved forever. The code above will happily return the expected HTTP status code 200

    >>> urllib.request.urlopen("https://www.google.com").status
    200


    So why is that? Why does calling curl fix my SSL issues in Python on Windows?

    PS. Actually I found another answer on stackoverflow, which suggested to call curl to fix network issues: https://stackoverflow.com/a/78372621/179014 . But no explanation is given, why that works.

    Continue reading...

Compartilhe esta Página