我有一个网络应用程序,可以对不同的站点进行curl 调用以获取数据。由于我的网络空间提供商(ionos)对服务器进行了一些更改,curl 调用不再起作用。我的卷曲调用如下所示:$ch = curl_init();curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);curl_setopt($ch, CURLOPT_URL, $link);curl_setopt($ch, CURLOPT_HEADER, false);curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);$sResult = curl_exec($ch);curl_close($ch);它不起作用。$s结果为空。我更改了代码并尝试了$test = file_get_contents($link);这给了我错误:PHP Warning: file_get_contents(): SSL operation failed with code 1. OpenSSL Error messages:error:141A318A:SSL routines:tls_process_ske_dhe:dh key too small我的curl 调用或file_get_contents 调用中是否缺少某些内容?
4 回答

ABOUTYOU
TA贡献1812条经验 获得超5个赞
对于此错误,通常的建议是将 /etc/ssl/openssl.cnf 中的“CipherString”参数设置为“DEFAULT:@SECLEVEL=1”。
在 PHP 中,您可以使用以下方法实现相同的目的curl_setopt()
:
curl_setopt($ch, CURLOPT_SSL_CIPHER_LIST, 'DEFAULT@SECLEVEL=1');
这是比编辑 openssl.cnf 更好的解决方案,因为它允许您放松仅针对一个特定调用(而不是系统范围)的安全性。

大话西游666
TA贡献1817条经验 获得超14个赞
如果您使用 file_get_contents() 函数,则效果很好
$context=array(
"ssl"=>array(
'ciphers' => 'DEFAULT:!DH'
),
);
$json = file_get_contents($url, false, stream_context_create($context));

繁星coding
TA贡献1797条经验 获得超4个赞
我在curl 命令行上收到此错误。
卷曲请求
curl -k --request POST --url 'https://abc.com.pk/token/api?grant_type=client_credentials' --header 'Authorization: Basic a0NiZXNMTXFlJBY1lBQjJINmtqWVFh' --ciphers DEFAULT@SECLEVEL=1
解决方案:
--ciphers DEFAULT@SECLEVEL=1
- 4 回答
- 0 关注
- 228 浏览
添加回答
举报
0/150
提交
取消