When I access http://www.google.com/
in my browser I'm redirected to https://www.google.com/
. I'm expecting CURLINFO_EFFECTIVE_URL
to return me https when running this code:
$ch = curl_init('http://google.com/');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");
curl_setopt($ch, CURLOPT_NOBODY, true);
echo curl_exec($ch); // echos nothing
echo curl_getinfo($ch, CURLINFO_HTTP_CODE); // echos '200'
echo curl_getinfo($ch, CURLINFO_EFFECTIVE_URL); // echos 'http://google.com/'
curl_close($ch);
Will adding a ssl cert and adding the following fields make this work as i'm expecting?
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_CAINFO, 'whateverCrt.crt');