2015-06-29 12 views
16

Tôi đang cố gắng truy cập và tải xuống một số tệp .torrent từ https://torrage.com sử dụng php curl. Nhưng không có gì xảy ra, curl_error($ch) choCách sửa lỗi curl: (35) Không thể liên lạc an toàn với ngang hàng: không có thuật toán mã hóa phổ biến

$ch = curl_init ('https://torrage.com/torrent/640FE84C613C17F663551D218689A64E8AEBEABE.torrent'); 
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); 
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0'); 
curl_setopt($ch, CURLOPT_HEADER, 1); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); 
curl_setopt($ch, CURLOPT_VERBOSE,true); 
$data = curl_exec($ch); 
$error = curl_error($ch); 
curl_close ($ch); 
echo $error; 

này cung cấp cho.

Cannot communicate securely with peer: no common encryption algorithm(s). 

Nếu tôi cố gắng từ vỏ như thế này

[[email protected] yum.repos.d]# curl -I https://torrage.com 
curl: (35) Cannot communicate securely with peer: no common encryption algorithm(s). 

trong chế độ verbose

[[email protected] yum.repos.d]# curl -v https://torrage.com 
* Rebuilt URL to: https://torrage.com/ 
* Trying 81.17.30.48... 
* Connected to torrage.com (81.17.30.48) port 443 (#0) 
* Initializing NSS with certpath: sql:/etc/pki/nssdb 
* CAfile: /etc/pki/tls/certs/ca-bundle.crt 
    CApath: none 
* NSS error -12286 (SSL_ERROR_NO_CYPHER_OVERLAP) 
* Cannot communicate securely with peer: no common encryption algorithm(s). 
* Closing connection 0 
curl: (35) Cannot communicate securely with peer: no common encryption algorithm(s). 

thông tin hệ thống centos 7. x86_64

[[email protected] yum.repos.d]# uname -a 
Linux prod1.localdomain 3.10.0-229.4.2.el7.x86_64 #1 SMP Wed May 13 10:06:09 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux 

curl phiên bản

[[email protected] yum.repos.d]# curl -V 
curl 7.29.0 (x86_64-redhat-linux-gnu) 

openssl, đã vá.

[[email protected] yum.repos.d]# openssl version -a 
OpenSSL 1.0.1e-fips 11 Feb 2013 
built on: Mon Jun 15 18:39:20 UTC 2015 
platform: linux-x86_64 
options: bn(64,64) md2(int) rc4(16x,int) des(idx,cisc,16,int) idea(int) blowfish(idx) 
compiler: gcc -fPIC -DOPENSSL_PIC -DZLIB -DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -DKRB5_MIT -m64 -DL_ENDIAN -DTERMIO -Wall -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -Wa,--noexecstack -DPURIFY -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DMD5_ASM -DAES_ASM -DVPAES_ASM -DBSAES_ASM -DWHIRLPOOL_ASM -DGHASH_ASM 
OPENSSLDIR: "/etc/pki/tls" 
engines: dynamic 

xác minh openssl patched or not.

[[email protected] yum.repos.d]# rpm -q --changelog openssl | grep CVE-2014-0224 
- fix CVE-2014-0224 fix that broke EAP-FAST session resumption support 
- fix CVE-2014-0224 - SSL/TLS MITM vulnerability 

gì tôi đã cố gắng:

1) tôi đã cố gắng sử dụng HTTP insted của HTTPS, nhưng các lực lượng tại chỗ để sử dụng HTTPS. ví dụ:

[[email protected] yum.repos.d]# curl -I http://torrage.com 
HTTP/1.1 301 Moved Permanently 
Server: nginx/1.9.0 
Date: Mon, 29 Jun 2015 04:13:17 GMT 
Content-Type: text/html 
Content-Length: 184 
Connection: keep-alive 
Location: https://torrage.com/ 

2) cập nhật ca-bundle.crt

cp /etc/pki/tls/certs/ca-bundle.crt /root/backup/ 
curl http://curl.haxx.se/ca/cacert.pem -o /etc/pki/tls/certs/ca-bundle.crt 

3) Cập nhật Curl mới nhất phiên bản 7.43.0

nano /etc/yum.repos.d/city-fan-for-curl.repo 

với repo này.

[CityFanforCurl] 
name=City Fan Repo 
baseurl=http://www.city-fan.org/ftp/contrib/yum-repo/rhel7/x86_64/ 
enabled=0 
gpgcheck=0 

và sau đó làm

yum update curl --enablerepo=CityFanforCurl 

sau đó xác minh curl phiên bản

[[email protected] yum.repos.d]# curl -V 
curl 7.43.0 (x86_64-redhat-linux-gnu) libcurl/7.43.0 NSS/3.18 Basic ECC zlib/1.2.7 libidn/1.28 libssh2/1.6.0 
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp scp sftp smb smbs smtp smtps telnet tftp 
Features: AsynchDNS IDN IPv6 Largefile GSS-API Kerberos SPNEGO NTLM NTLM_WB SSL libz UnixSockets Metalink 

4) tôi đã cố gắng này để kiểm tra xem curl của tôi là lỗi thời hay không.

tham khảo: https://unix.stackexchange.com/questions/162816/disable-sslv3-in-curl

[[email protected] yum.repos.d]# curl -1IsS --ciphers ecdhe_ecdsa_aes_128_sha https://sslspdy.com 
HTTP/1.1 200 OK 
Server: nginx centminmod 
Content-Type: text/html; charset=utf-8 
Connection: close 
Vary: Accept-Encoding 
Strict-Transport-Security: max-age=31536000; includeSubdomains 
Date: Mon, 12 Jan 1970 23:00:11 GMT 
X-Page-Speed: ngx_pagespeed 
Cache-Control: max-age=0, no-cache 

Làm thế nào tôi có thể khắc phục vấn đề? và tải xuống các tệp từ Torrage.com bằng cách sử dụng PHP Curl?

* Tôi không thể sử dụng file_get_contents vì tôi đang sử dụng curl_multi để tải xuống đồng thời.


Cập nhật 1:

Theo đề nghị của Steffen-Ullrich

[[email protected] randoadmin]# curl --ciphers ecdhe_rsa_aes_128_gcm_sha_256 -I https://torrage.com 
HTTP/1.1 200 OK 
Server: nginx/1.9.0 
Date: Mon, 29 Jun 2015 05:54:17 GMT 
Content-Type: text/html; charset=UTF-8 
Connection: keep-alive 
Expires: Mon, 26 Jul 1997 05:00:00 GMT 
Last-Modified: Mon, 29 Jun 2015 05:50:40 GMT 
Cache-Control: no-store, no-cache, must-revalidate 
Cache-Control: post-check=0, pre-check=0 
Pragma: no-cache 
Vary: Accept-Encoding, Accept-Encoding 
Strict-Transport-Security: max-age=31536000 
X-Frame-Options: DENY 
X-Content-Type-Options: nosniff 

nhưng thats với vỏ làm thế nào tôi có thể thực hiện nó với PHP-curl?

Cập nhật 2:

tôi đã sửa đổi mã và xác định mật mã để sử dụng trong khi sử dụng curl như thế này.

$ch = curl_init ('https://torrage.com/torrent/640FE84C613C17F663551D218689A64E8AEBEABE.torrent'); 
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); 
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0'); 
curl_setopt($ch, CURLOPT_HEADER, 1); 
curl_setopt($ch, CURLOPT_SSL_CIPHER_LIST, 'ecdhe_rsa_aes_128_gcm_sha_256'); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); 
curl_setopt($ch, CURLOPT_VERBOSE,true); 
$data = curl_exec($ch); 
$error = curl_error($ch); 
curl_close ($ch); 
echo $error; 
echo $data ; 

Làm việc tuyệt vời. Vấn đề được giải quyết nhiều nhờ có steffen-ullrich.

+0

Bạn đã nâng cấp gói openssl của mình chưa? –

+0

@ Ja͢ck nope, tôi đang thử nó ngay bây giờ. Cảm ơn – AMB

+0

@ Ja͢ck vâng, nó đã được vá. chỉ cần kiểm tra, ref: http://www.liquidweb.com/kb/update-and-patch-openssl-for-the-ccs-injection-vulnerability/ – AMB

Trả lời

16

Máy chủ chỉ hỗ trợ mật mã ECC (ECDHE- *). Phiên bản curl được xây dựng với thư viện NSS trên Redhat/CentOS. Có một báo cáo lỗi rằng Redhat/CentOS ghi đè cài đặt curl và disables ECC ciphers by default. Bởi vì không có mật mã ECC do khách hàng cung cấp nhưng chỉ có mật mã ECC được máy chủ hỗ trợ kết nối sẽ thất bại.

Bạn có thể cố gắng để cung cấp cho một cách rõ ràng mật mã, ví dụ:

curl --ciphers ecdhe_rsa_aes_128_gcm_sha_256 ... 

Lưu ý rằng việc nâng cấp OpenSSL sẽ không giúp đỡ vì curl không được xây dựng với sự phụ trợ OpenSSL. Ngoài ra nó không giúp vô hiệu hóa xác nhận chứng chỉ (ý tưởng tồi anyway) hoặc thay đổi gốc của CA vì vấn đề không liên quan đến xác thực chứng chỉ.

Cố gắng cung cấp mật mã một cách rõ ràng với --ciphers ecdhe_ecdsa_aes_128_sha làm mật mã để giải quyết vấn đề đi đúng hướng nhưng sẽ không trợ giúp trong trường hợp này, vì đây không phải là một trong các mật mã được máy chủ hỗ trợ. Máy chủ chỉ hỗ trợ các mật mã ECDHE-RSA- * khác nhau nhưng không hỗ trợ các thuật toán mã hóa ECDHE-ECDSA- *. Xem SSLLabs để biết chi tiết.

+0

Cảm ơn, cho đầu vào của bạn, nó rất nặng đối với tôi hiểu mật mã , nhưng tôi đang học, cho đến nay nó làm việc trên vỏ, nhưng làm thế nào tôi có thể xác định mật mã trong yêu cầu curl php? cảm ơn – AMB

+1

@AMB: Nếu bạn sử dụng tài liệu tại http://php.net/manual/en/function.curl-setopt.php và bạn sẽ tìm thấy cài đặt CURLOPT_SSL_CIPHER_LIST. –

+0

cảm ơn, mã cố định và hoạt động của nó như sự quyến rũ. tôi thực sự đánh giá cao nó., – AMB

7

Nếu bạn đang sử dụng CentOS 7 và đang gặp phải những lỗi này khi sử dụng yum, việc cập nhật nss-nss-nss-nss-sss-nss-tools sẽ sửa lỗi đó.

+3

Sau khoảng 2 giờ gỡ lỗi, thiết lập nhiều tùy chọn cho curl trong trang php của tôi, bạn đã lưu tôi. Cảm ơn bạn! Nếu bạn đang sử dụng VPS và lệnh gọi lệnh curl cho 'curl: (35) Không thể kết nối an toàn với lỗi peer', hãy thử cập nhật yum ở trên, sẽ giúp ích. lệnh là: 'yum cập nhật nss nss-util nss-sysinit nss-tools' – redDevil

-1

Cả hai cách trên đều không hiệu quả đối với tôi. Tôi nghi ngờ nó đã làm với phiên bản Curl. Curl_version(); trả về 7,29, trong khi trên máy chủ tôi đã cài đặt 7,49,1, có thể đã khắc phục được sự cố SSL đó.

Đột nhiên tôi đã nhớ về Cloudflare và CDN bị vô hiệu hóa chỉ trong trường hợp. Curl bắt đầu làm việc. Sau đó, tôi chuyển sang PHP 7 và Curl bắt đầu làm việc ngay cả với Cloudflare CDN. Curl_version(); bắt đầu quay lại 7.49.1.

Tôi không biết làm thế nào mà làm việc và những gì chính xác đã xảy ra, nhưng sau giờ không mệt mỏi của tìm kiếm giải pháp này là những gì tôi tìm thấy.

+0

Mặc dù đây có thể là thông tin có giá trị nhưng đây không phải là câu trả lời. –

+0

Câu trả lời là: khi không có tác phẩm nào ở trên, hãy kiểm tra phiên bản Curl và cập nhật nó. Đã có thông tin giá trị này được ở đây một ngày trước ngày hôm qua, nó đã có thể cứu tôi hai ngày trong cuộc đời tôi. – Walt

0

Ngoài ra còn có khả năng để kiểm tra

trên unix (hy vọng giành chiến thắng cũng):

> curl -v https://www.youtube.com > test.html 

lưu ý: thay thế "https://www.youtube.com" với tên miền của bạn với giao thức

Chỉ đạo sản xuất để thử nghiệm .html vì vậy chúng tôi sẽ chỉ nhìn thấy thông tin mong muốn trên màn hình

kết quả:

* Rebuilt URL to: https://www.youtube.com/ 
* Hostname was NOT found in DNS cache 
    % 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 2404:6800:4005:80d::200e... 
* Trying 216.58.221.238... 
    0  0 0  0 0  0  0  0 --:--:-- --:--:-- --:--:--  0* Connected to www.youtube.com (2404:6800:4005:80d::200e) port 443 (#0) 
* successfully set certificate verify locations: 
* CAfile: none 
    CApath: /etc/ssl/certs/ 
* SSLv3, TLS Unknown, Unknown (22): 
} [data not shown] 
* SSLv3, TLS handshake, Client hello (1): 
} [data not shown] 
* SSLv2, Unknown (22): 
{ [data not shown] 
* SSLv3, TLS handshake, Server hello (2): 
{ [data not shown] 
* SSLv2, Unknown (22): 
{ [data not shown] 
* SSLv3, TLS handshake, CERT (11): 
{ [data not shown] 
* SSLv2, Unknown (22): 
{ [data not shown] 
* SSLv3, TLS handshake, Server key exchange (12): 
{ [data not shown] 
* SSLv2, Unknown (22): 
{ [data not shown] 
* SSLv3, TLS handshake, Server finished (14): 
{ [data not shown] 
* SSLv2, Unknown (22): 
} [data not shown] 
* SSLv3, TLS handshake, Client key exchange (16): 
} [data not shown] 
* SSLv2, Unknown (20): 
} [data not shown] 
* SSLv3, TLS change cipher, Client hello (1): 
} [data not shown] 
* SSLv2, Unknown (22): 
} [data not shown] 
* SSLv3, TLS handshake, Finished (20): 
} [data not shown] 
* SSLv2, Unknown (20): 
{ [data not shown] 
* SSLv3, TLS change cipher, Client hello (1): 
{ [data not shown] 
* SSLv2, Unknown (22): 
{ [data not shown] 
* SSLv3, TLS handshake, Finished (20): 
{ [data not shown] 
* SSL connection using TLSv1.2/ECDHE-ECDSA-AES128-GCM-SHA256 
* Server certificate: 
*  subject: C=US; ST=California; L=Mountain View; O=Google Inc; CN=*.google.com 
*  start date: 2017-11-29 09:44:32 GMT 
*  expire date: 2018-02-21 09:37:00 GMT 
*  subjectAltName: www.youtube.com matched 
*  issuer: C=US; O=Google Inc; CN=Google Internet Authority G2 
*  SSL certificate verify ok. 
* SSLv2, Unknown (23): 
} [data not shown] 
> GET/HTTP/1.1 
> User-Agent: curl/7.37.0 
> Host: www.youtube.com 
> Accept: */* 
> 
* SSLv2, Unknown (23): 
{ [data not shown] 
< HTTP/1.1 200 OK 
< Content-Type: text/html; charset=utf-8 
< X-XSS-Protection: 1; mode=block; report=https://www.google.com/appserve/security-bugs/log/youtube 
< X-Content-Type-Options: nosniff 
< X-Frame-Options: SAMEORIGIN 
< Expires: Tue, 27 Apr 1971 19:44:06 EST 
< Strict-Transport-Security: max-age=31536000 
< P3P: CP="This is not a P3P policy! See http://support.google.com/accounts/answer/151657?hl=uk for more info." 
< Cache-Control: no-cache 
< Date: Tue, 26 Dec 2017 12:26:21 GMT 
* Server YouTube Frontend Proxy is not blacklisted 
< Server: YouTube Frontend Proxy 
< Set-Cookie: YSC=lkUUrudTNJM; path=/; domain=.youtube.com; httponly 
< Set-Cookie: PREF=f1=50000000; path=/; domain=.youtube.com; expires=Mon, 27-Aug-2018 00:19:21 GMT 
< Set-Cookie: VISITOR_INFO1_LIVE=Qo2rlICrfJM; path=/; domain=.youtube.com; expires=Mon, 27-Aug-2018 00:19:21 GMT; httponly 
< Alt-Svc: hq=":443"; ma=2592000; quic=51303431; quic=51303339; quic=51303338; quic=51303337; quic=51303335,quic=":443"; ma=2592000; v="41,39,38,37,35" 
< Accept-Ranges: none 
< Vary: Accept-Encoding 
< Transfer-Encoding: chunked 
< 
{ [data not shown] 
100 152 0 152 0  0 114  0 --:--:-- 0:00:01 --:--:-- 114* SSLv2, Unknown (23): 
{ [data not shown] 
* SSLv2, Unknown (23): 
{ [data not shown] 
* SSLv2, Unknown (23): 
{ [data not shown] 
* SSLv2, Unknown (23): 

.......... many-other-same-not-interesting-rows ......... 

{ [data not shown] 
* SSLv2, Unknown (23): 
{ [data not shown] 
100 425k 0 425k 0  0 113k  0 --:--:-- 0:00:03 --:--:-- 113k 
* Connection #0 to host www.youtube.com left intact 

Xem:

* kết nối SSL sử dụng TLSv1.2/ECDHE-ECDSA-AES128-GCM-SHA256

và sử dụng:

curl_setopt($ch, CURLOPT_SSL_CIPHER_LIST, 'ECDHE-ECDSA-AES128-GCM-SHA256'); 
0

On Centos 7 hoặc ở trên nâng cấp curl lên phiên bản mới nhất tức là 7.29. * đã khắc phục sự cố cho tôi.

Các vấn đề liên quan