如何在aiohttp请求中更改SSL版本?

时间:2019-04-26 12:28:46

标签: python python-requests aiohttp

根据解决requests中的问题的建议

Caused by SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:645)SSLErrorEOF occurred in violation of protocol

我可以做一些事情:

class MyAdapter(HTTPAdapter):
    def init_poolmanager(self, connections, maxsize, block=False, **pool_kwargs):
        self.poolmanager = PoolManager(
            num_pools=connections,
            maxsize=maxsize,
            block=block,
            ssl_version=ssl.PROTOCOL_TLSv1
        )
# then 
import requests
s=requests.session()
s.mount("https://", MyAdapter)

如何使用aiohttp做同样的事情?

1 个答案:

答案 0 :(得分:2)

ssl_context 是您可以使用的字段。检查一下:

https://docs.python.org/3/library/ssl.html#ssl.SSLContext