首页 > 解决方案 > 卷曲 OpenSSL 错误 141A318A tls_process_ske_dhe:dh 密钥太小

问题描述

我有一个 web 应用程序,它对不同的站点进行 curl 调用以获取数据。由于我的网络空间提供商 (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 调用中是否缺少某些内容?

标签: phpcurlhttpsopenssl

解决方案


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

在 PHP 中,您可以通过以下方式实现相同的目的curl_setopt()

curl_setopt($ch, CURLOPT_SSL_CIPHER_LIST, 'DEFAULT@SECLEVEL=1');

这是一个比编辑 openssl.cnf 更好的解决方案,因为它允许您仅放松一个特定调用的安全性,而不是系统范围的安全性。


推荐阅读