简体   繁体   English

如何在PHP CURL中使用ECDHE密码?

[英]How to use ECDHE ciphers in PHP CURL?

I used nmap to scan, this is the result: 我使用nmap进行扫描,结果如下:

在此处输入图片说明

Looks like they only support ECDHE, from output of openssl_get_cipher_methods() , there is no ECDHE cipher! 看起来他们只支持ECDHE,从openssl_get_cipher_methods()输出openssl_get_cipher_methods() ,没有ECDHE密码! So my question is how can I connect to the remote server using PHP CURL client? 所以我的问题是如何使用PHP CURL客户端连接到远程服务器?

This is my sample PHP code which is returned false with the message: 这是返回false与消息我的样本PHP代码:

"Unknown cipher in list: ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES128-SHA", curl error number code is 59 (Couldn't use specified cipher.) “列表中的未知密码:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-SHA256: ECDHE-RSA-AES128-SHA”,卷曲错误编号代码为59 (无法使用指定的密码。)

$ch = curl_init(); 
curl_setopt($ch, CURLOPT_SSL_CIPHER_LIST, "ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES128-SHA"); 
curl_setopt($ch, CURLOPT_SSLVERSION, 6); 
curl_setopt($ch, CURLOPT_URL, "xxxxxxxxxxxxxxx"); 
var_dump(curl_exec($ch)); 
var_dump(curl_error($ch)); 
var_dump(curl_errno($ch));

I'm using PHP 5.3.29, openssl 1.0.1e-fips 11 Feb 2013 我正在使用PHP 5.3.29,openssl 1.0.1e-fips 2013年2月11日

The format of 'CURLOPT_SSL_CIPHER_LIST' depends on the library your cURL is linked against. “ CURLOPT_SSL_CIPHER_LIST”的格式取决于您的cURL链接到的库。 If you are running on a RedHat-derived Linux, it is NSS rather than GNUTLS (Ubuntu) or OpenSSL, so you will need to convert the names accordingly. 如果您在RedHat衍生的Linux上运行,则为NSS而不是GNUTLS(Ubuntu)或OpenSSL,因此您需要相应地转换名称。

The following question should help you: 以下问题应为您提供帮助:

https://unix.stackexchange.com/questions/208437/how-to-convert-ssl-ciphers-to-curl-format https://unix.stackexchange.com/questions/208437/how-to-convert-ssl-ciphers-to-curl-format

I found the root cause, I'm running CentOS with NSS package 3.19. 我找到了根本原因,我正在使用NSS软件包3.19运行CentOS。 By default, this version doesn't enable ECC ciphers (ECDHE is one of ECC ciphers), Its fixed after upgrade to NSS 3.21+. 默认情况下,此版本不启用ECC密码(ECDHE是ECC密码之一),在升级到NSS 3.21+后已修复。

https://bugzilla.mozilla.org/show_bug.cgi?id=1205688
https://developer.mozilla.org/en-US/docs/Mozilla/Projects/NSS/NSS_3.21_release_notes
https://tools.ietf.org/html/rfc4492

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM