Python Requests throwing SSLError

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

    If the request calls are buried somewhere deep in the code and you do not want to install the server certificate, then, just for debug purposes only, it's possible to monkeypatch requests:

    import requests.api
    import warnings
    
    
    def requestspatch(method, url, **kwargs):
        kwargs['verify'] = False
        return _origcall(method, url, **kwargs)
    
    _origcall = requests.api.request
    requests.api.request = requestspatch
    warnings.warn('Patched requests: SSL verification disabled!')
    

    Never use in production!

提交回复
热议问题