php - 如何让 PHP 连接到仅限 TLSv1.2 的站点

标签 php ssl curl

<分区>

我正在尝试使用 PHP 中的 curl 连接到 Pronto Cycle Share (使用 PHP 5.6.2)。该站点在浏览器和命令行 curl 中运行。

根据 SSL Labs , 它只接受 TLS 1.2。

在 PHP 中,使用 CURL(版本 7.28.1)PHP 无法协商并给我 Curl error: error:14094410:SSL routines:SSL3_READ_BYTES:sslv3 alert handshake failure

使用file_get_contents,代码:

$ctx = stream_context_create([
'ssl' => [
    'crypto_method' => STREAM_CRYPTO_METHOD_TLS_CLIENT
  ],
]);
$html = file_get_contents($url, false, $ctx);

返回:

Message:  file_get_contents(): SSL operation failed with code 1. OpenSSL Error messages: error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure

print_r(OPENSSL_VERSION_TEXT) 说 OpenSSL 0.9.8r 2011 年 2 月 8 日,所以这已经相当老了。我在 Mac 上使用 MAMP PRO。

有什么方法可以使用简单的 PHP 方法连接到此服务器吗?

最佳答案

您的 cURL 版本不支持 TLS 1.2,您需要升级。

CURL_SSLVERSION_TLSv1_0 (4), CURL_SSLVERSION_TLSv1_1 (5) or CURL_SSLVERSION_TLSv1_2 (6) only work for PHP versions using curl 7.34 or newer.

Source

关于php - 如何让 PHP 连接到仅限 TLSv1.2 的站点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26722982/

相关文章:

php - 修改jQuery日历列

ssl - Windows7-64 位上的 PyQt4.QtWebKit.QWebView 是否适用于 SSL 站点?

python - 如何在python中修改_ssl

ssl - 仅来自某些服务器的链中自签名证书

ios - Swift 将 cURL -user key 转换为 AFNetworking 的 json

php/curl - 使用 header 获取远程服务器上的图像扩展

curl - 如何使用 cURL 调试 SSL 握手?

java - 为什么 Fortify SCA 针对我的项目中不再存在的文件报告问题?

php - 如何不在 php 中静态调用函数?

php - orderBy 在 Laravel 5 中不起作用