So beheben Sie Curl: (35) Kann nicht sicher mit Peer kommunizieren: keine gemeinsamen Verschlüsselungsalgorithmen

Lesezeit: 10 Minuten

Ich versuche, auf einige zuzugreifen und sie herunterzuladen .torrent Dateien aus https://torrage.com verwenden php curl. Aber nichts passiert , curl_error($ch) gibt

$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;

das gibt.

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

Wenn ich es von der Shell so versuche

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

im ausführlichen Modus

[root@prod1 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).

Systeminformationen Centos 7. x86_64

[root@prod1 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-Version

[root@prod1 yum.repos.d]# curl -V
curl 7.29.0 (x86_64-redhat-linux-gnu)

openssl , bereits gepatcht.

[root@prod1 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

Überprüfen, ob Openssl gepatcht ist oder nicht.

[root@prod1 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

Was ich probiert habe:

1) Ich habe versucht, HTTP anstelle von HTTPS zu verwenden, aber die Site erzwingt die Verwendung von HTTPS. z.B

[root@prod1 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) Aktualisieren von 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) Aktualisieren von Curl auf die neueste Version 7.43.0

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

mit diesem Repo.

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

und dann tun

yum update curl --enablerepo=CityFanforCurl

dann Überprüfung der Curl-Version

[root@prod1 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) Ich habe dies versucht, um zu überprüfen, ob meine Locke veraltet ist oder nicht.

Hinweis: https://unix.stackexchange.com/questions/162816/disable-sslv3-in-curl

[root@prod1 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

Wie kann ich das Problem beheben? und Dateien von Torrage.com herunterladen PHP Curl ?

* Ich kann file_get_contents nicht so verwenden, wie ich es verwende curl_multi für gleichzeitige Downloads.


Aktualisierung 1:

Wie vorgeschlagen von steffen-ulrich

[root@prod1 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

aber das ist mit Shell, wie kann ich es implementieren PHP-curl ?

Aktualisierung 2:

Ich habe den Code geändert und die Chiffre definiert, die bei der Verwendung von Curl wie folgt verwendet werden soll.

$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 ;

Es funktioniert großartig. Problem gelöst vielen Dank an steffen-ulrich .

  • Haben Sie auch Ihr openssl-Paket aktualisiert?

    – Jack

    29. Juni 2015 um 4:43 Uhr

  • @Ja͢ck nein, ich versuche es jetzt. Vielen Dank

    Benutzer1642018

    29. Juni 2015 um 4:44 Uhr

  • @Ja͢ck ja, es ist bereits gepatcht. gerade nachgeschaut, ref: liquidweb.com/kb/…

    Benutzer1642018

    29. Juni 2015 um 4:48 Uhr


Benutzer-Avatar
Steffen Ulrich

Der Server unterstützt nur ECC-Chiffren (ECDHE-*). Die Version von curl wird mit der NSS-Bibliothek auf Redhat/CentOS erstellt. Es gibt einen Fehlerbericht, dass Redhat/CentOS die Curl-Einstellungen überschreibt und deaktiviert ECC-Chiffren standardmäßig. Da somit vom Client keine ECC-Chiffren angeboten werden, sondern vom Server nur ECC-Chiffren unterstützt werden, schlägt die Verbindung fehl.

Sie könnten versuchen, die Chiffre explizit anzugeben, dh

curl --ciphers ecdhe_rsa_aes_128_gcm_sha_256 ...

Beachten Sie, dass ein Upgrade von OpenSSL nicht helfen würde, da curl nicht mit dem OpenSSL-Backend erstellt wurde. Es hilft auch nicht, die Zertifikatsvalidierung zu deaktivieren (sowieso eine schlechte Idee) oder die Root-CAs zu ändern, da das Problem überhaupt nicht mit der Zertifikatsvalidierung zusammenhängt.

Der Versuch, die Chiffre explizit mit anzugeben --ciphers ecdhe_ecdsa_aes_128_sha da die Chiffre zur Lösung des Problems in die richtige Richtung geht, hilft in diesem Fall aber nicht weiter, da dies keine der von den Servern unterstützten Chiffren ist. Der Server unterstützt nur verschiedene ECDHE-RSA-*-Chiffren, aber keine ECDHE-ECDSA-*-Chiffren. Sehen SSLLabs für Details.

  • Danke, für Ihre Eingabe, es ist sehr schwer für mich, die Chiffren zu verstehen, aber ich lerne, bisher funktioniert es auf der Shell, aber wie kann ich die Chiffre in der PHP-Curl-Anfrage definieren? Danke

    Benutzer1642018

    29. Juni 2015 um 5:58 Uhr

  • @AMB: Wenn Sie die Dokumentation unter verwenden php.net/manual/en/function.curl-setopt.php und Sie finden die Einstellung CURLOPT_SSL_CIPHER_LIST.

    – Steffen Ullrich

    29. Juni 2015 um 6:00 Uhr


  • danke, fester Code und es funktioniert wie Charme. Ich schätze es wirklich.,

    Benutzer1642018

    29. Juni 2015 um 6:01 Uhr

  • für mich curl_setopt($ch, CURLOPT_SSL_CIPHER_LIST, ‘ecdhe_rsa_aes_128_gcm_sha_256’); funktionierte, da es sich um eine andere Torrent-Site handelte.

    – vrtech77

    21. Dezember 2015 um 6:08 Uhr


Wenn Sie CentOS 7 verwenden und diese Fehler bei der Verwendung von yum erhalten, wird die Aktualisierung von nss nss-util nss-sysinit nss-tools das Problem beheben.

  • Nach etwa 2 Stunden Debugging, dem Festlegen mehrerer Optionen für Curl auf meiner PHP-Seite, haben Sie mich gerettet. Vielen Dank! Wenn Sie auf einem VPS sind und einen Curl-Befehlszeilenaufruf geben curl: (35) Cannot communicate securely with peer Fehler, versuchen Sie es mit Yum Update, sollte helfen. Befehl ist: yum update nss nss-util nss-sysinit nss-tools

    – roter Teufel

    23. Mai 2016 um 20:11 Uhr


Auf Centos 7 oder höher wurde das Problem durch ein Upgrade von Curl auf die neueste Version, dh 7.29. *, für mich behoben.

  • Es hat für mich funktioniert, nachdem ich die obigen Chiffren und nss-Update-Vorschläge ausprobiert hatte.

    – Manuel

    10. Januar 2019 um 10:13 Uhr

Es besteht auch die Möglichkeit zu überprüfen

unter Unix (hoffe auch gewinnen):

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

Hinweis: ersetzen “https://www.youtube.com” mit Ihrer Domain mit Protokoll

Die Ausgabe wird an test.html geleitet, sodass nur die gewünschten Informationen auf dem Bildschirm angezeigt werden

Ergebnis:

* 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

Sehen:

* SSL-Verbindung mit TLSv1.2 / ECDHE-ECDSA-AES128-GCM-SHA256

und verwenden:

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

Keines der oben genannten hat bei mir funktioniert. Ich vermutete, dass es mit der Curl-Version zu tun hatte. Curl_version(); gab 7.29 zurück, während ich auf dem Server 7.49.1 installierte, bei dem diese SSL-Probleme wahrscheinlich behoben waren.

Plötzlich erinnerte ich mich an Cloudflare und deaktivierte CDN für alle Fälle. Curl begann zu arbeiten. Dann wechselte ich zu PHP 7 und Curl begann sogar mit Cloudflare CDN zu arbeiten. Curl_version(); begann mit der Rückgabe von 7.49.1.

Ich weiß nicht, wie das funktioniert hat und was genau passiert ist, aber nach unermüdlichen Stunden der Suche nach der Lösung habe ich das gefunden.

  • Auch wenn dies wertvolle Informationen sein könnten, ist es keine Antwort.

    – Jared Smith

    8. Juli 2016 um 14:51 Uhr

  • Die Antwort lautet: Wenn nichts davon funktioniert, überprüfen Sie die Curl-Version und aktualisieren Sie sie. Wäre diese wertvolle Information vorgestern hier gewesen, hätte sie mir zwei Tage meines Lebens gerettet.

    – Walt

    8. Juli 2016 um 18:15 Uhr

  • Auch wenn dies wertvolle Informationen sein könnten, ist es keine Antwort.

    – Jared Smith

    8. Juli 2016 um 14:51 Uhr

  • Die Antwort lautet: Wenn nichts davon funktioniert, überprüfen Sie die Curl-Version und aktualisieren Sie sie. Wäre diese wertvolle Information vorgestern hier gewesen, hätte sie mir zwei Tage meines Lebens gerettet.

    – Walt

    8. Juli 2016 um 18:15 Uhr

1144780cookie-checkSo beheben Sie Curl: (35) Kann nicht sicher mit Peer kommunizieren: keine gemeinsamen Verschlüsselungsalgorithmen

This website is using cookies to improve the user-friendliness. You agree by using the website further.

Privacy policy