3

I'm having issues with Windows MAMP Pro 3.3.1 getting PHP's CURL to work.

More specifically issue is that I can send requests to APIs using curl_exec, but it always returns false.

When I tried to do the same thing with XAMPP it returns full response with no issues.

I tried changing PHP version, I checked that php curl extensions is enabled and I can see CURL info in phpinfo.

Does any one know why and how to fix this issue with MAMP?

2

2 Answers 2

8

So I've seen the issue. Apparently (still need to investigate), a CURL request does not get the certificate from the browser, unlike HTTPS. We'll need to manually download the certificate of the site and add it to the PHP ini.

I got the certificate from here:

https://curl.haxx.se/ca/cacert.pem

Add the path to php.ini. You should see ;curl.cainfo under [curl]. Uncomment and add the path:

curl.cainfo = "path_to_cert\cacert.pem"

Restart apache and it'll work (at least mine did).

Sign up to request clarification or add additional context in comments.

6 Comments

I dont' even have [curl] and [openssl] entries in any MAMP php.ini file.
Adding curl.cainfo = "path_to\cacert.pem" to php.ini did the trick. You should undo your answer so I can vote it up.
Thank you very much Thomas. I hope that MAMP will fix this issue in Windows MAMP 4.
In case it helps, my php.ini file is located at /Applications/MAMP/bin/php/php7.1.1/conf/php.ini
I have this same issue, tried all the solution I've seen so far on this problem, still not solution. I'm using MAMP. In my php.ini i used this curl.cainfo ="/Applications/MAMP/conf/apache/extra/cacert.pem" as the url for curl. I used var_dump(php_ini_loaded_file()); to get my php ini location, this was what I got string(48) "/Applications/MAMP/bin/php/php7.2.8/conf/php.ini" still no solution. Any other suggestion will be appreciated.
|
2

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);

1 Comment

It works in macos too. Thanks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.