開發日記:aws emr api 接口開發php
Today I was trying to consume an external video API for streaming a set of videos; so I got the code for the PHP source, create all my configuration but when I tried to get the actual data from the external server via cURL; I was obtaining nothing; so, in order to get the error’s message, this is what I did:api
var_dump(curl_error($ch));
Which basically gets the error after the connection. The message was the following one:curl
SSL certificate problem: unable to get local issuer certificateide
1) Download the certificate from http://curl.haxx.se/ca/cacert.pemui
2) Create a folder under your home:this
mkdir /Users/alex/ssl
3) Copy or move the file with the certificate you just downloaded:url
mv /Users/alex/Downloads/cacert.pem /Users/alex/ssl
4) Open your php.ini and look for this directive curl.cainfo (the path should vary, depending on your system or meta-package you are using: WAMP, XAMPP, AMPPS have different paths).spa
[curl]; A defaultvaluefor the CURLOPT_CAINFO option. This is required to be an; absolute path.curl.cainfo =
5) Type there you path to the certificate; for example in my case, this was the configuration I did:code
curl.cainfo = /Users/alex/ssl/cacert.pem
6) Restart your Apache.server
7) Enjoy!
稍後可能會有curl 77的錯誤:
http://curl.haxx.se/ca/cacert.pem 下載或者複製粘貼成一個cacert.pem文檔
若是你的php環境是window 下,用的集成環境xamp 之類的,那麼,我建議大家將那個cacert.pem放置到xampp下面,才能解決77的錯誤