Python Requests throwing SSLError

前端 未结 24 3159
小蘑菇
小蘑菇 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:31

    I encountered the same issue and ssl certificate verify failed issue when using aws boto3, by review boto3 code, I found the REQUESTS_CA_BUNDLE is not set, so I fixed the both issue by setting it manually:

    from boto3.session import Session
    import os
    
    # debian
    os.environ['REQUESTS_CA_BUNDLE'] = os.path.join(
        '/etc/ssl/certs/',
        'ca-certificates.crt')
    # centos
    #   'ca-bundle.crt')
    

    For aws-cli, I guess setting REQUESTS_CA_BUNDLE in ~/.bashrc will fix this issue (not tested because my aws-cli works without it).

    REQUESTS_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt # ca-bundle.crt
    export REQUESTS_CA_BUNDLE
    

提交回复
热议问题