gpt4 book ai didi

python-3.x - Docker 中的 SSL UNSUPPORTED_PROTOCOL Python 3

转载 作者:太空宇宙 更新时间:2023-11-03 13:08:45 29 4
gpt4 key购买 nike

我尝试通过 https 从网站获取数据并收到 SSL 证书错误,但是当我在我的 mac 上运行时 - 一切正常。

我也尝试使用 curl 并得到了同样的错误,

curl: (35) error:1425F102:SSL routines:ssl_choose_client_version:unsupported protocol

我在 Docker 容器中运行解析器我的 Dockerfile:

FROM python:3.7

WORKDIR /parser
COPY ./requirements.txt .

RUN python -m pip install --upgrade pip

RUN pip install -r requirements.txt

COPY . /parser

我收到以下错误:

 Traceback (most recent call last):                                                                                                                                                                                                       │
│ File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 672, in urlopen │
│ chunked=chunked, │
│ File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 376, in _make_request │
│ self._validate_conn(conn) │
│ File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 994, in _validate_conn │
│ conn.connect() │
│ File "/usr/local/lib/python3.7/site-packages/urllib3/connection.py", line 394, in connect │
│ ssl_context=context, │
│ File "/usr/local/lib/python3.7/site-packages/urllib3/util/ssl_.py", line 370, in ssl_wrap_socket │
│ return context.wrap_socket(sock, server_hostname=server_hostname) │
│ File "/usr/local/lib/python3.7/ssl.py", line 423, in wrap_socket │
│ session=session │
│ File "/usr/local/lib/python3.7/ssl.py", line 870, in _create │
│ self.do_handshake() │
│ File "/usr/local/lib/python3.7/ssl.py", line 1139, in do_handshake │
│ self._sslobj.do_handshake() │
│ ssl.SSLError: [SSL: UNSUPPORTED_PROTOCOL] unsupported protocol (_ssl.c:1076) │
│ During handling of the above exception, another exception occurred: │
│ Traceback (most recent call last): │
│ File "/usr/local/lib/python3.7/site-packages/requests/adapters.py", line 449, in send │
│ timeout=timeout │
│ File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 720, in urlopen │
│ method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2] │
│ File "/usr/local/lib/python3.7/site-packages/urllib3/util/retry.py", line 436, in increment │
│ raise MaxRetryError(_pool, url, error or ResponseError(cause)) │
│ urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='life.pravda.com.ua', port=443): Max retries exceeded with url: /health/ (Caused by SSLError(SSLError(1, '[SSL: UNSUPPORTED_PROTOCOL] unsupported protocol (_ssl.c:1076)')) │
│ )

最佳答案

我在 Dockerfile 中使用以下命令解决了我的问题:

RUN    apt-get update \
&& apt-get install openssl \
&& apt-get install ca-certificates

并且还需要在requirements.txt中添加python包pyopenssl

关于python-3.x - Docker 中的 SSL UNSUPPORTED_PROTOCOL Python 3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58268626/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com