用php curl打开一个安全的网页

时间:2016-07-21 22:46:37

标签: php security ssl curl

我想使用PHP Curl打开以下网站(使用安全连接):

$url = "www.missjoias.com.br";
$url = "www.perfumes.com.br";

以下是代码:

<?php
$handle=curl_init($url);
curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
curl_setopt($handle, CURLOPT_HEADER, false);
curl_setopt($handle, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($handle, CURLOPT_ENCODING, "");
curl_setopt($handle, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 5.1; rv:31.0) Gecko/20100101 Firefox/31.0');
curl_setopt($handle, CURLOPT_AUTOREFERER, true);
curl_setopt($handle, CURLOPT_CONNECTTIMEOUT, 120);
curl_setopt($handle, CURLOPT_TIMEOUT, 120);
curl_setopt($handle, CURLOPT_MAXREDIRS, true);
curl_setopt($handle, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($handle, CURLOPT_SSL_VERIFYHOST, 2);
//curl_setopt($handle, CURLOPT_CAINFO, $_SERVER['DOCUMENT_ROOT'] . "/ca-bundle.crt.txt");
$content = curl_exec($handle);
echo $content; // show target page
exit;

?>

有关ca-bundle.crt.txt的行已注释,但我已尝试使用和不使用它。 我总是得到一个http 403 Forbidden访问响应。 有什么帮助吗?

0 个答案:

没有答案