Search the Community
Showing results for tags 'curl headers ssl https'.
-
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