4

我正在 Docker Alpine 映像中编写一个简单的网络爬虫。但是,我无法将 HTTPS 请求发送到仅支持 TLS1.0 的服务器。如何配置 Alpine linux 以允许过时的 TLS 版本?

我尝试添加MinProtocol没有/etc/ssl/openssl.cnf运气。

示例 Dockerfile:

FROM node:12.0-alpine

RUN printf "[system_default_sect]\nMinProtocol = TLSv1.0\nCipherString = DEFAULT@SECLEVEL=1" >> /etc/ssl/openssl.cnf

CMD ["/usr/bin/wget", "https://www.restauracesalanda.cz/"]

当我构建并运行这个容器时,我得到

Connecting to www.restauracesalanda.cz (93.185.102.124:443)
ssl_client: www.restauracesalanda.cz: handshake failed: error:1425F102:SSL routines:ssl_choose_client_version:unsupported protocol
wget: error getting response: Connection reset by peer
4

2 回答 2

2

我可以使用 builtin-busybox-wget 重现您的问题。但是,使用“常规” wget 可以:

root@a:~# docker run --rm -it node:12.0-alpine /bin/ash
/ # wget -q https://www.restauracesalanda.cz/; echo $?
ssl_client: www.restauracesalanda.cz: handshake failed: error:1425F102:SSL routines:ssl_choose_client_version:unsupported protocol
wget: error getting response: Connection reset by peer
1
/ # apk add wget
fetch http://dl-cdn.alpinelinux.org/alpine/v3.9/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.9/community/x86_64/APKINDEX.tar.gz
(1/1) Installing wget (1.20.3-r0)
Executing busybox-1.29.3-r10.trigger
OK: 7 MiB in 17 packages
/ # wget -q https://www.restauracesalanda.cz/; echo $?
0
/ #

我不确定,但也许你应该在https://bugs.alpinelinux.org发布问题

于 2019-05-07T08:25:07.917 回答
0

将这个神奇的 1 衬垫放入我的 dockerfile 解决了我的问题,并且我能够使用 TLS 1.0:

RUN sed -i 's/MinProtocol = TLSv1.2/MinProtocol = TLSv1/' /etc/ssl/openssl.cnf \ && sed -i 's/CipherString = DEFAULT@SECLEVEL=2/CipherString = DEFAULT@SECLEVEL=1/' /etc/ssl/openssl.cnf

归功于这个家伙:http ://blog.travisgosselin.com/tls-1-0-1-1-docker-container-support/

于 2021-02-03T17:27:49.100 回答