嗨,我现在正在做一个网站。这两个文件都在一个服务器和域中,我正在使用cloudflare来提高负载。我在cloudflare上使用完全SSL选项,因为我在服务器上购买了自己的SSL Geotrust。我已经在服务器上将curl升级到了7.41.0。
一个php文件由函数组成
功能文件:
<?php
function get_content($session){
$endpoint = "https://sample.ph/php/resource.php";
// Use one of the parameter configurations listed at the top of the post
$params = array(
"yel" => $session
);
$curl = curl_init();
curl_setopt($curl,CURLOPT_URL,$endpoint);
$strCookie = 'PHPSESSID='.$_COOKIE['PHPSESSID'];
curl_setopt($curl, CURLOPT_COOKIE, $strCookie);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_VERBOSE, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2);
$postData = "";
//This is needed to properly form post the credentials object
foreach($params as $k => $v)
{
$postData .= $k . '='.urlencode($v).'&';
}
$postData = rtrim($postData, '&');
curl_setopt($curl, CURLOPT_POSTFIELDS, $postData);
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 60);
curl_setopt($curl, CURLOPT_HEADER, 0); // Don’t return the header, just the html
curl_setopt($curl, CURLOPT_CAINFO,"/home/sample/public_html/php/cacert.pem"); // Set the location of the CA-bundle
session_write_close();
$response = curl_exec($curl);
if ($response === FALSE) {
return "cURL Error: " . curl_error($curl);
}
else{
// evaluate for success response
return $response;
}
curl_close($curl);
}
?>
资源文件
<?php
session_start();
if(isset($_POST['yel'])){
$drcyt_key = dcrypt("{$_POST['yel']}");
if($drcyt_key == $_SESSION['token']){
echo "Success";
}
}
?>
你认为我该怎么解决这个问题?
SSL验证错误。在调试时,有时我会遇到cURL错误:SSL证书问题,请验证CA证书是否正常。详细信息:错误:14090086:SSL例程:SSL_3_GET_SERVER_certificate:证书验证失败
有时我会收到cURL错误:SSL对等证书或SSH远程密钥不正常
当我放入curl_setopt($curl,CURLOPT_SSL_VERIFYPEER,true);设置为FALSE,这不是一个好主意;SESSION COOKIE在第一次加载时变为空白,这带来了第二个问题。
我希望你能帮助我。谢谢。
此问题看起来是服务器上过时的证书捆绑包或过时的OpenSSL版本。您既应该确保您的计算机上有最新的根证书,也应该确保您有最新版本的OpenSSL(包括PHP OpenSSL模块)。