php curl 请求总是 return 错误
php curl request always return false
我准备了一个 url 用户凭据来验证客户端和 return 文件
我 post 它与 php 5.6.13 中的 curl 在此代码段中:
$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);
但是响应总是错误的..
我运行 ch_error($ch)
它returns
"Peer certificate cannot be authenticated with known CA certificates" what does this mean ?
这是目标页面:
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);
}
}
由于您使用的是私有 IP 并且(很可能是虚拟 ssl 证书),您需要为您的请求禁用 ssl 验证。
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
但请注意,这是一个安全风险。所以在生产环境中避免这种情况
我准备了一个 url 用户凭据来验证客户端和 return 文件 我 post 它与 php 5.6.13 中的 curl 在此代码段中:
$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);
但是响应总是错误的..
我运行 ch_error($ch)
它returns
"Peer certificate cannot be authenticated with known CA certificates" what does this mean ?
这是目标页面:
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);
}
}
由于您使用的是私有 IP 并且(很可能是虚拟 ssl 证书),您需要为您的请求禁用 ssl 验证。
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
但请注意,这是一个安全风险。所以在生产环境中避免这种情况