curl与浏览器的结果不同

时间:2019-05-03 22:46:01

标签: ssl curl openssl libcurl

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

在此here之前曾问过这个问题,但是没有有效的答案。我按照建议尝试了-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 

1 个答案:

答案 0 :(得分:2)

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

curl --tlsv1.3 -v 'https://floridakeyswebcams.tv/sloppycam/camarchive/0807.jpg'

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

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

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

./CURL.EXE https://floridakeyswebcams.tv/sloppycam/camarchive/0807.jpg --tlsv1.3 -v
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current

                                 Dload  Upload   Total   Spent    Left  Speed

* TCP_NODELAY set

* Connected to floridakeyswebcams.tv (74.209.245.140) port 443 (#0)

> GET /sloppycam/camarchive/0807.jpg HTTP/1.1


> Host: floridakeyswebcams.tv


> User-Agent: curl/7.64.1


> Accept: */*


> 

▒▒▒▒
\▒.▒:\▒.▒:▒▒











▒▒
%&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒

-截断的jpg二进制-

关于为什么不进行自动协商的问题仍然存在,我不确定,但是我想您的TLS后端不支持tlv1.3,这可能与为什么您只得到了一个神秘主义者有关错误..