PHP: fetch an URL via SSL

Brad Roberts braddr at puremagic.com
Wed Apr 2 13:40:26 PDT 2014


On 4/2/14, 1:28 PM, Andrei Alexandrescu wrote:
> Brad Roberts is trying to switch bugzilla to use https, which breaks
> https://github.com/D-Programming-Language/dlang.org/blob/master/fetch-issue-cnt.php. He's not a PHP
> guy so he wouldn't know how to fix it. Could I trust one of our contributors to take on this task?
>
> Thanks,
>
> Andrei

I pointed you to a url that contains a couple excellent answers this morning:

     http://stackoverflow.com/questions/1975461/file-get-contents-with-https

 From that page, the primary problem is the php install on dlang.org's webserver lacks either 
configuration or a php extension and it's configuration:

Add this to the php config file:

     extension=php_openssl.dll
     allow_url_fopen = On

Alternately, if the curl extension is installed, it looks like this code would be an alternative 
implementation:

function getSslPage($url) {
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
     curl_setopt($ch, CURLOPT_HEADER, false);
     curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
     curl_setopt($ch, CURLOPT_URL, $url);
     curl_setopt($ch, CURLOPT_REFERER, $url);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
     $result = curl_exec($ch);
     curl_close($ch);
     return $result;
}

But the community doesn't have access to the server, so the best anyone external can do is provide 
this sort of data or setup an external proxy server, which is a horrible solution.


More information about the Digitalmars-d mailing list