gpt4 book ai didi

linux - debian 9 上关于 HTTPS 的 curl 命令行 API 更改

转载 作者:太空宇宙 更新时间:2023-11-04 12:10:11 26 4
gpt4 key购买 nike

Debian 9 curl 中是否有任何命令行 API 更改?

最近我开始使用 Debian 9(9.4,来自 Debian 8.x)并且涉及 curl 的脚本停止工作。我通过连接到父代理的本地主机上的鱿鱼代理连接到互联网。

我的环境变量是这样配置的

root@server:~# printenv | grep -i proxy
HTTP_PROXY=http://127.0.0.1:3128
FTP_PROXY=http://127.0.0.1:3128
https_proxy=https://127.0.0.1:3128
http_proxy=http://127.0.0.1:3128
HTTPS_PROXY=https://127.0.0.1:3128
ftp_proxy=http://127.0.0.1:3128

当我使用 wget 时,它有效:

root@server:~# wget https://www.google.com.cu
--2018-03-14 09:08:53-- https://www.google.com.cu/
Connecting to 127.0.0.1:3128... connected.
Proxy request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: ‘index.html’

index.html [ <=> ] 11.12K --.-KB/s in 0.001s

2018-03-14 09:08:54 (14.9 MB/s) - ‘index.html’ saved [11389]

当我使用 curl 时,这是我得到的结果

root@server:~# curl -v https://www.google.com.cu
* Rebuilt URL to: https://www.google.com.cu/
* Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to (nil) (127.0.0.1) port 3128 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
* successfully set certificate verify locations:
* CAfile: none
CApath: /etc/ssl/certs
* TLSv1.2 (OUT), TLS header, Certificate Status (22):
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
* error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol
* Curl_http_done: called premature == 0
* Closing connection 0
curl: (35) error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol

我知道这两个命令不是等价的,这只是为了说明HTTPS传输问题。

我需要使用curl,因为脚本使用了一个web API,所以它需要使用POST而不是GET请求,并为POST请求设置一些头部和数据。 (api.dropboxapi.com 是目标站点)

这一切过去都可以在 Debian 8 上顺利运行,除了 wget WORKS 之外,只有 curl 在 debian 版本更改时失败。所有其他 HTTPS 客户端似乎不受影响(FF、Chrome、Edge、wget 似乎都一如既往地工作)

是否有任何解决方法、修复、命令行选项更改或任何使 debian 9 版本的 curl 工作的方法?

一定有办法,我无法想象 curl 无法与 google 建立 HTTPS 连接。必须有命令行或允许连接的东西。

“curl -V”的输出

root@server:~# curl -V
curl 7.52.1 (x86_64-pc-linux-gnu) libcurl/7.52.1 OpenSSL/1.0.2l zlib/1.2.8 libidn2/0.16 libpsl/0.17.0 (+libidn2/0.16) libssh2/1.7.0 nghttp2/1.18.1 librtmp/2.3
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtmp rtsp scp sftp smb smbs smtp smtps telnet tftp
Features: AsynchDNS IDN IPv6 Largefile GSS-API Kerberos SPNEGO NTLM NTLM_WB SSL libz TLS-SRP HTTP2 UnixSockets HTTPS-proxy PSL

按照建议输出“curl --insecure”

root@server:~# curl --insecure -v https://www.google.com.cu
* Rebuilt URL to: https://www.google.com.cu/
* Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to (nil) (127.0.0.1) port 3128 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
* successfully set certificate verify locations:
* CAfile: none
CApath: /etc/ssl/certs
* TLSv1.2 (OUT), TLS header, Certificate Status (22):
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
* error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol
* Curl_http_done: called premature == 0
* Closing connection 0
curl: (35) error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol

“curl -v https://www.google.com.cu --sslv2”输出

root@server:/etc/squid# curl -v https://www.google.com.cu --sslv2
* Rebuilt URL to: https://www.google.com.cu/
* Trying 192.168.4.65...
* TCP_NODELAY set
* Connected to (nil) (192.168.4.65) port 81 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
* successfully set certificate verify locations:
* CAfile: none
CApath: /etc/ssl/certs
* TLSv1.2 (OUT), TLS header, Certificate Status (22):
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
* error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol
* Curl_http_done: called premature == 0
* Closing connection 0
curl: (35) error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol

最佳答案

非常非常感谢 Michael Hampton。事实证明问题出在代理配置中。应该说

https_proxy=http://127.0.0.1:3128
HTTPS_PROXY=http://127.0.0.1:3128

因此 curl 尝试使用 TLS 连接到 squid,当然失败了。

https://serverfault.com/questions/901626/debian-version-change-affecting-scripts-using-curl-and-https 中的原始答案

关于linux - debian 9 上关于 HTTPS 的 curl 命令行 API 更改,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49280968/

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