[英]php curl request always return false
I prepared a url with user credentials to validate client and return the file I post it with curl in php 5.6.13 within this code piece: 我准备了一个带有用户凭据的url来验证客户端,并返回在以下代码段中我用curl在php 5.6.13中发布的文件:
$url ="https://192.168.0.15:10445/wfmi/Infrastructure/getFile.php?filenamecentraldb=".$_GET["filename"]."&username=administrator&password=passwordofadmin";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);
But response is always false.. 但是回应总是错误的。
I run ch_error($ch)
and it returns 我运行
ch_error($ch)
并返回
"Peer certificate cannot be authenticated with known CA certificates" what does this mean ?
“对等证书无法使用已知的CA证书进行身份验证”是什么意思?
Here is the target page: 这是目标页面:
if(isset($_GET["filenamecentraldb"]))
{
error_log("Check1");//never reach there...
try
{
$username = $_GET["username"];
$password = $_GET["password"];
...
exit(0);
}
catch (PDOException $e)
{
echo "Error ocurred:".$e->getMessage();
exit(0);
}
catch (Exception $e)
{
echo "Error ocurred:".$e->getMessage();
exit(0);
}
}
Since you're using private IPs and (most likely a dummy ssl certificate), you need to disable ssl verification for your requests. 由于您使用的是专用IP和(很可能是虚拟ssl证书),因此您需要针对请求禁用ssl验证。
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
But be aware that this is a security risk. 但是请注意,这是安全隐患。 So avoid this in a production environment
因此,在生产环境中避免这种情况
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.