PHP CURL & HTTPS

前端 未结 4 1251
深忆病人
深忆病人 2020-11-22 09:25

I found this function that does an AWESOME job (IMHO): http://nadeausoftware.com/articles/2007/06/php_tip_how_get_web_page_using_curl

/**
 * Get a web file (         


        
4条回答
  •  名媛妹妹
    2020-11-22 09:45

    Another option like Gavin Palmer answer is to use the .pem file but with a curl option

    1. download the last updated .pem file from https://curl.haxx.se/docs/caextract.html and save it somewhere on your server(outside the public folder)

    2. set the option in your code instead of the php.ini file.

    In your code

    curl_setopt($ch, CURLOPT_CAINFO, $_SERVER['DOCUMENT_ROOT'] .  "/../cacert-2017-09-20.pem");
    

    NOTE: setting the cainfo in the php.ini like @Gavin Palmer did is better than setting it in your code like I did, because it will save a disk IO every time the function is called, I just make it like this in case you want to test the cainfo file on the fly instead of changing the php.ini while testing your function.

提交回复
热议问题