Python SSL certificate verify error

前端 未结 2 821
谎友^
谎友^ 2020-12-03 08:43

I\'m using requests to access a RESTful API. Everything seems to work. I can authenticate, pull back a session token and even unit test the methods in my class I wrote for

2条回答
  •  一个人的身影
    2020-12-03 08:59

    I have found this over here

    I found this solution, insert this code at the beginning of your source file:

    import ssl
    
    try:
        _create_unverified_https_context = ssl._create_unverified_context
    except AttributeError:
        # Legacy Python that doesn't verify HTTPS certificates by default
        pass
    else:
        # Handle target environment that doesn't support HTTPS verification
        ssl._create_default_https_context = _create_unverified_https_context
    

提交回复
热议问题