Jump to content

cURL returns no headers with HTTPS


mHo2

Recommended Posts

Hey All,
I previously asked this question on stackoverflow to no avail:
http://stackoverflow.com/questions/19734022/curl-returns-no-result-with-https-header-read
 

It reads:

I've got an issue with cURL here. I'm attempting to retrieve a status code from a webpage and I simply cannot with my internal URL. It uses Self-Signed Certs. performing the cURL operation below simply results in a boolean false value.

  • If I attempt to use cURL through my linux box, it correctly returns the header. (as expected)
  • If I attempt to use cURL through PHP with a URL such as https://www.google.com, it successfully returns a header (as expected)
  • If I attempt to use cURL through PHP with a URL such as https://www.google.com while taking out the SSL_VERIFY options, it does not return a header (as expected)

Can anyone explain this behaviour?

function get_http_response_code($url) {
$url = 'https://host.name.com/test.html';
$headers = getheaders($url);
//echo($headers);
echo(substr($headers,9,3));
}
function getheaders($url) {
$c = curl_init();
//echo($url);
curl_setopt($c, CURLOPT_URL, $url);
//curl_setopt($c, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($c, CURLOPT_HEADER, true);
curl_setopt($c, CURLOPT_NOBODY, true);
// curl_setopt($ch, CURLOPT_SSLVERSION, 3);
// curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($c, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($c, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
$headers = curl_exec($c);
//echo(var_dump(curl_error($headers)));
//echo(var_dump($headers));
curl_close($c);
return $headers;
}

 

 

Thanks again,

-Mat

Link to comment
https://forums.phpfreaks.com/topic/283541-curl-returns-no-headers-with-https/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.