猿问

Curl OpenSSL 错误 141A318A tls_process_ske_dhe:dh

我有一个网络应用程序,可以对不同的站点进行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 调用中是否缺少某些内容?


qq_遁去的一_1
浏览 229回答 4
4回答

ABOUTYOU

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

大话西游666

如果您使用 file_get_contents() 函数,则效果很好$context=array(    "ssl"=>array(        'ciphers' => 'DEFAULT:!DH'    ),); $json = file_get_contents($url, false, stream_context_create($context));

MMTTMM

要解决该问题,必须通过以下方式启用旧密码套件:update-crypto-policies --set LEGACY

繁星coding

我在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
随时随地看视频慕课网APP
我要回答