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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.