PHP CURL & HTTPS

前端 未结 4 1256
深忆病人
深忆病人 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 10:03

    I was trying to use CURL to do some https API calls with php and ran into this problem. I noticed a recommendation on the php site which got me up and running: http://php.net/manual/en/function.curl-setopt.php#110457

    Please everyone, stop setting CURLOPT_SSL_VERIFYPEER to false or 0. If your PHP installation doesn't have an up-to-date CA root certificate bundle, download the one at the curl website and save it on your server:

    http://curl.haxx.se/docs/caextract.html

    Then set a path to it in your php.ini file, e.g. on Windows:

    curl.cainfo=c:\php\cacert.pem

    Turning off CURLOPT_SSL_VERIFYPEER allows man in the middle (MITM) attacks, which you don't want!

提交回复
热议问题