我有一个get应用程序,它对不同的站点进行curl调用以获取数据。由于我的the空间提供商( is )对服务器进行了一些更改,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调用中是否缺少了什么?
发布于 2020-11-02 19:16:36
对于此错误,通常的建议是将/etc/ssl/openssl.cnf中的CipherString参数设置为DEFAULT:@SECLEVEL=1。
在PHP中,您可以使用curl_setopt()实现相同的功能。
curl_setopt($ch, CURLOPT_SSL_CIPHER_LIST, 'DEFAULT@SECLEVEL=1');这是一个比编辑openssl.cnf更好的解决方案,因为它允许您只针对一个特定的调用放松安全性,而不是整个系统。
发布于 2021-03-08 12:27:42
如果使用的是file_get_contents()函数,则可以很好地执行此操作
$context=array(
"ssl"=>array(
'ciphers' => 'DEFAULT:!DH'
),
);
$json = file_get_contents($url, false, stream_context_create($context));https://stackoverflow.com/questions/63235805
复制相似问题