curl 与浏览器的结果不同

spa*_*spa 3 ssl curl openssl libcurl

我正在尝试使用curl 从命令行下载以下URL。如果通过浏览器请求相同的 URL,则能够获取图像。但对于curl,服务器终止SSL握手。只是为了使用完全相同的参数;我尝试了 google-chrome 和 firefox 的“开发人员工具”中的curl 命令。但两者都失败并出现以下错误。

这个问题之前在这里被问过,但没有有效的答案。我按照建议尝试了 -http1.1 但没有成功。

https://floridakeyswebcams.tv/sloppycam/camarchive/0807.jpg

(base) (15:39 test@testcomp ~) > curl -v 'https://floridakeyswebcams.tv/sloppycam/camarchive/0807.jpg' -H 'Connection: keep-alive' -H 'Upgrade-Insecure-Requests: 1' -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.131 Safari/537.36' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3' -H 'Accept-Encoding: gzip, deflate, br' -H 'Accept-Language: en-US,en;q=0.9,hi;q=0.8,mr;q=0.7' -H 'If-None-Match: "90cbf2d5a81d51:da782"' -H 'If-Modified-Since: Fri, 03 May 2019 12:07:53 GMT' --compressed
*   Trying 74.209.245.140...
* TCP_NODELAY set
* Connected to floridakeyswebcams.tv (74.209.245.140) port 443 (#0)
* ALPN, offering http/1.1
* successfully set certificate verify locations:
*   CAfile: /home/sagham/anaconda2/ssl/cacert.pem
  CApath: none
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
* OpenSSL SSL_connect: SSL_ERROR_SYSCALL in connection to         floridakeyswebcams.tv:443 
* Closing connection 0
curl: (35) OpenSSL SSL_connect: SSL_ERROR_SYSCALL in connection to floridakeyswebcams.tv:443 
Run Code Online (Sandbox Code Playgroud)

han*_*rik 5

看来 floridakeyswebcams.tv 需要 TLS1.3 支持,请使用--tlsv1.3参数,

\n
curl --tlsv1.3 -v 'https://floridakeyswebcams.tv/sloppycam/camarchive/0807.jpg'\n
Run Code Online (Sandbox Code Playgroud)\n

这是我使用时得到的--tlsv1.2

\n
$ ./CURL.EXE https://floridakeyswebcams.tv/sloppycam/camarchive/0807.jpg --tlsv1.2 -vv\n  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current\n                                 Dload  Upload   Total   Spent    Left  Speed\n  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0*   Trying 74.209.245.140...\n* TCP_NODELAY set\n* Connected to floridakeyswebcams.tv (74.209.245.140) port 443 (#0)\n* schannel: next InitializeSecurityContext failed: SEC_E_ALGORITHM_MISMATCH (0x80090331) - The client and server cannot communicate, because they do not possess a common algorit\n  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0\n* Closing connection 0\n* schannel: shutting down SSL/TLS connection with floridakeyswebcams.tv port 443\ncurl: (35) schannel: next InitializeSecurityContext failed: SEC_E_ALGORITHM_MISMATCH (0x80090331) - The client and server cannot communicate, because they do not possess a common algorit\n
Run Code Online (Sandbox Code Playgroud)\n

这是(大致上,由于某种原因它以错误的顺序打印)如果我使用我会得到什么--tlsv1.3

\n
./CURL.EXE https://floridakeyswebcams.tv/sloppycam/camarchive/0807.jpg --tlsv1.3 -v\n  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current\n\n                                 Dload  Upload   Total   Spent    Left  Speed\n\n* TCP_NODELAY set\n\n* Connected to floridakeyswebcams.tv (74.209.245.140) port 443 (#0)\n\n> GET /sloppycam/camarchive/0807.jpg HTTP/1.1\n\n\n> Host: floridakeyswebcams.tv\n\n\n> User-Agent: curl/7.64.1\n\n\n> Accept: */*\n\n\n> \n\n\xe2\x96\x92\xe2\x96\x92\xe2\x96\x92\xe2\x96\x92\n\\\xe2\x96\x92.\xe2\x96\x92:\\\xe2\x96\x92.\xe2\x96\x92:\xe2\x96\x92\xe2\x96\x92\n\n\n\n\n\n\n\n\n\n\n\n\xe2\x96\x92\xe2\x96\x92\n%&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz\xe2\x96\x92\xe2\x96\x92\xe2\x96\x92\xe2\x96\x92\xe2\x96\x92\xe2\x96\x92\xe2\x96\x92\xe2\x96\x92\xe2\x96\x92\xe2\x96\x92\xe2\x96\x92\xe2\x96\x92\xe2\x96\x92\xe2\x96\x92\xe2\x96\x92\xe2\x96\x92\xe2\x96\x92\xe2\x96\x92\xe2\x96\x92\xe2\x96\x92\xe2\x96\x92\xe2\x96\x92\xe2\x96\x92\xe2\x96\x92\xe2\x96\x92\xe2\x96\x92\xe2\x96\x92\xe2\x96\x92\xe2\x96\x92\xe2\x96\x92\xe2\x96\x92\xe2\x96\x92\xe2\x96\x92\xe2\x96\x92\xe2\x96\x92\xe2\x96\x92\xe2\x96\x92\xe2\x96\x92\xe2\x96\x92\xe2\x96\x92\xe2\x96\x92\xe2\x96\x92\xe2\x96\x92\xe2\x96\x92\xe2\x96\x92\xe2\x96\x92\xe2\x96\x92\xe2\x96\x92\xe2\x96\x92\xe2\x96\x92\xe2\x96\x92\xe2\x96\x92\xe2\x96\x92\xe2\x96\x92\xe2\x96\x92\xe2\x96\x92\xe2\x96\x92\xe2\x96\x92\xe2\x96\x92\xe2\x96\x92\xe2\x96\x92\xe2\x96\x92\xe2\x96\x92\xe2\x96\x92\xe2\x96\x92\xe2\x96\x92\xe2\x96\x92\xe2\x96\x92\xe2\x96\x92\xe2\x96\x92\xe2\x96\x92\xe2\x96\x92\xe2\x96\x92\xe2\x96\x92\xe2\x96\x92\n
Run Code Online (Sandbox Code Playgroud)\n

-截断的 jpg 二进制文件-

\n

问题仍然是关于为什么这不是自动协商的,我不确定,但我猜你的 TLS 后端不支持 tlv1.3,这可能与你刚刚收到一个神秘错误的原因有关。

\n