php - curl OpenSSL错误141A318A tls_process_ske_dhe :dh key too small

标签 php curl https openssl

我有一个Web应用程序,该应用程序向另一个站点进行curl调用以获取数据。
由于我的Webspace提供程序(ionos)对服务器进行了一些更改,因此curl调用不再起作用。
我的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);
它没有工作。 $ sResult为空。
我更改了代码并尝试
$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调用中是否缺少某些内容?

最佳答案

对于此错误的通常建议是将CipherString中的/etc/ssl/openssl.cnf参数设置为DEFAULT:@SECLEVEL=1

  • https://askubuntu.com/a/1233456
  • https://imlc.me/dh-key-too-small

  • 在PHP中,您可以使用 curl_setopt() 实现相同的目的:
    curl_setopt($ch, CURLOPT_SSL_CIPHER_LIST, 'DEFAULT@SECLEVEL=1');
    
    与编辑openssl.cnf相比,这是一种更好的解决方案,因为它使您可以放宽一个特定调用的安全性,而不是整个系统的安全性。

    关于php - curl OpenSSL错误141A318A tls_process_ske_dhe :dh key too small,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63235805/

    相关文章:

    php - Facebook PHP SDK 抛出无法捕获的 "GraphMethodException"错误

    php - 来自多个表的 SELECT 命令中的交叉关联 PhP/Mysql 字段

    rest - 如何将此 REST 请求形成为 header 、基本身份验证

    angularjs - 将脚本 curl 到 angularjs 后调用

    ssl - Nginx HTTPS 连接被拒绝

    iis - 在 IIS 下使用 SSL 的多个子域

    python - Django 相对 url 和 https

    php - 输入类型提交与输入类型按钮

    php - PHP ':' 语句末尾的 'if' 是什么意思?

    curl - 在文件上传中使用curl来处理多部分/表单数据