"Correct way" 从安全 SSL 路径调用什么 运行 这个 php curl 函数?
What is the "Correct way" to call and run this php curl function from a secure SSL path?
我一直在仔细查看这段代码,它不是我创建的,一旦您从安全的 SSL 路径调用它并在整个过程中使用安全路径,它就会停止工作。我添加了几行希望能解决 SSL 问题,但没有成功。无法联系到创建此内容的原始人,因此我希望我只是遗漏了一些我不明白的东西。
我不使用 PHP,所以我希望了解更多关于为什么这在通过 SSL 路径调用时不起作用。我四处寻找答案,但没有找到解决这个问题的答案。
文件 运行 使用非 SSL 路径即 http://www.example.com/sub/filename.php, but all I get back is a False when I run the file by calling it by this url https://www.example.com/sub/filename.php 出现零问题。
php 日志显示了这一点。
[16-Aug-2019 15:05:35 UTC] PHP Deprecated: Automatically populating $HTTP_RAW_POST_DATA is deprecated and will be removed in a future version. To avoid this warning set 'always_populate_raw_post_data' to '-1' in php.ini and use the php://input stream instead. in Unknown on line 0
[16-Aug-2019 15:05:35 UTC] PHP Deprecated: Automatically populating $HTTP_RAW_POST_DATA is deprecated and will be removed in a future version. To avoid this warning set 'always_populate_raw_post_data' to '-1' in php.ini and use the php://input stream instead. in Unknown on line 0
[16-Aug-2019 15:05:35 UTC] PHP Deprecated: Automatically populating $HTTP_RAW_POST_DATA is deprecated and will be removed in a future version. To avoid this warning set 'always_populate_raw_post_data' to '-1' in php.ini and use the php://input stream instead. in Unknown on line 0
[16-Aug-2019 15:05:35 UTC] PHP Deprecated: Automatically populating $HTTP_RAW_POST_DATA is deprecated and will be removed in a future version. To avoid this warning set 'always_populate_raw_post_data' to '-1' in php.ini and use the php://input stream instead. in Unknown on line 0
在此先感谢您的帮助。
<?php
error_reporting(0);
ini_set("display_errors", 0);
$DEBUG = false;
if($DEBUG) { echo "<h1>From Data File {$_GET['s']}</h1>"; }
$info = file_get_contents($_SERVER['DOCUMENT_ROOT']."/_tempfiles/_ses/{$_GET['s']}");
list($url,$vars,$header) = explode("||^||",$info);
unlink($_SERVER['DOCUMENT_ROOT']."/_tempfiles/_ses/{$_GET['s']}");
if(preg_match("|\r\n|",$header)) {
$theaders = explode("\r\n",$header);
}
else {
$theaders = explode("\n",$header);
}
foreach($theaders as $t) {
if(trim($t) != '') {
list($field,$value) = explode(':',$t);
if(trim($field) != 'Host') {
$headers[] = trim($t);
}
}
}
if($DEBUG) {
echo "<H1>URL</H1>{$url}";
echo "<H1>Headers Array (w/Host removed)</H1>";
var_dump($headers);
echo "<H1>Vars</H1>{$vars}";
echo "<H1>Content Length Validation</H1>".strlen($vars);
echo "<h1>Output From Remote URL below line:</h1>";
echo "<HR>";
}
$ch = curl_init();
// Configure curl for website
curl_setopt($ch, CURLOPT_URL,$url);
// Turn on SSL certificate verfication
curl_setopt($curl, CURLOPT_CAPATH, "/home/domain/unc/cacert.pem");
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 1);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, TRUE);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$vars);
if(isset($headers) && is_array($headers) && count($headers) > 0) {
//curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
}
// 1 second for a connection timeout with curl
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 5);
// Try using this instead of the php set_time_limit function call
curl_setopt($curl, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
$server_output = curl_exec ($ch);
curl_close ($ch);
echo $server_output;
?>
看来我提供的代码工作正常。我只需要检查此软件也传递 var 字符串的 return 路径。因此,感谢您的帮助,希望这可以帮助其他人解决同样的问题。
我一直在仔细查看这段代码,它不是我创建的,一旦您从安全的 SSL 路径调用它并在整个过程中使用安全路径,它就会停止工作。我添加了几行希望能解决 SSL 问题,但没有成功。无法联系到创建此内容的原始人,因此我希望我只是遗漏了一些我不明白的东西。
我不使用 PHP,所以我希望了解更多关于为什么这在通过 SSL 路径调用时不起作用。我四处寻找答案,但没有找到解决这个问题的答案。
文件 运行 使用非 SSL 路径即 http://www.example.com/sub/filename.php, but all I get back is a False when I run the file by calling it by this url https://www.example.com/sub/filename.php 出现零问题。
php 日志显示了这一点。
[16-Aug-2019 15:05:35 UTC] PHP Deprecated: Automatically populating $HTTP_RAW_POST_DATA is deprecated and will be removed in a future version. To avoid this warning set 'always_populate_raw_post_data' to '-1' in php.ini and use the php://input stream instead. in Unknown on line 0
[16-Aug-2019 15:05:35 UTC] PHP Deprecated: Automatically populating $HTTP_RAW_POST_DATA is deprecated and will be removed in a future version. To avoid this warning set 'always_populate_raw_post_data' to '-1' in php.ini and use the php://input stream instead. in Unknown on line 0
[16-Aug-2019 15:05:35 UTC] PHP Deprecated: Automatically populating $HTTP_RAW_POST_DATA is deprecated and will be removed in a future version. To avoid this warning set 'always_populate_raw_post_data' to '-1' in php.ini and use the php://input stream instead. in Unknown on line 0
[16-Aug-2019 15:05:35 UTC] PHP Deprecated: Automatically populating $HTTP_RAW_POST_DATA is deprecated and will be removed in a future version. To avoid this warning set 'always_populate_raw_post_data' to '-1' in php.ini and use the php://input stream instead. in Unknown on line 0
在此先感谢您的帮助。
<?php
error_reporting(0);
ini_set("display_errors", 0);
$DEBUG = false;
if($DEBUG) { echo "<h1>From Data File {$_GET['s']}</h1>"; }
$info = file_get_contents($_SERVER['DOCUMENT_ROOT']."/_tempfiles/_ses/{$_GET['s']}");
list($url,$vars,$header) = explode("||^||",$info);
unlink($_SERVER['DOCUMENT_ROOT']."/_tempfiles/_ses/{$_GET['s']}");
if(preg_match("|\r\n|",$header)) {
$theaders = explode("\r\n",$header);
}
else {
$theaders = explode("\n",$header);
}
foreach($theaders as $t) {
if(trim($t) != '') {
list($field,$value) = explode(':',$t);
if(trim($field) != 'Host') {
$headers[] = trim($t);
}
}
}
if($DEBUG) {
echo "<H1>URL</H1>{$url}";
echo "<H1>Headers Array (w/Host removed)</H1>";
var_dump($headers);
echo "<H1>Vars</H1>{$vars}";
echo "<H1>Content Length Validation</H1>".strlen($vars);
echo "<h1>Output From Remote URL below line:</h1>";
echo "<HR>";
}
$ch = curl_init();
// Configure curl for website
curl_setopt($ch, CURLOPT_URL,$url);
// Turn on SSL certificate verfication
curl_setopt($curl, CURLOPT_CAPATH, "/home/domain/unc/cacert.pem");
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 1);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, TRUE);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$vars);
if(isset($headers) && is_array($headers) && count($headers) > 0) {
//curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
}
// 1 second for a connection timeout with curl
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 5);
// Try using this instead of the php set_time_limit function call
curl_setopt($curl, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
$server_output = curl_exec ($ch);
curl_close ($ch);
echo $server_output;
?>
看来我提供的代码工作正常。我只需要检查此软件也传递 var 字符串的 return 路径。因此,感谢您的帮助,希望这可以帮助其他人解决同样的问题。