Python Requests throwing SSLError

前端 未结 24 2972
小蘑菇
小蘑菇 2020-11-22 02:49

I\'m working on a simple script that involves CAS, jspring security check, redirection, etc. I would like to use Kenneth Reitz\'s python requests because it\'s a great piec

24条回答
  •  無奈伤痛
    2020-11-22 03:37

    I have found an specific approach for solving a similar issue. The idea is pointing the cacert file stored at the system and used by another ssl based applications.

    In Debian (I'm not sure if same in other distributions) the certificate files (.pem) are stored at /etc/ssl/certs/ So, this is the code that work for me:

    import requests
    verify='/etc/ssl/certs/cacert.org.pem'
    response = requests.get('https://lists.cacert.org', verify=verify)
    

    For guessing what pem file choose, I have browse to the url and check which Certificate Authority (CA) has generated the certificate.

    EDIT: if you cannot edit the code (because you are running a third app) you can try to add the pem certificate directly into /usr/local/lib/python2.7/dist-packages/requests/cacert.pem (e.g. copying it to the end of the file).

提交回复
热议问题