MailChimp API V2.0 SSL error solution

I got this SSL error while trying to use MailChimp API V2.0 in my localhost.

Fatal error: Uncaught exception 'Mailchimp_HttpError' with message 'API call to lists/list failed: SSL certificate problem, verify that the CA cert is OK. Details: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed' in C:\Installation\xampp\htdocs\mailchimp-test\Mailchimp.php:192 Stack trace: #0 C:\Installation\xampp\htdocs\mailchimp-test\mailchimp-api.php(16): Mailchimp->call('lists/list', Array) #1 {main} thrown in C:\Installation\xampp\htdocs\mailchimp-test\Mailchimp.php on line 192 

To resolve this, you can try any of the methods below.

Method 1:
  • Download cacert.pem file from here: http://curl.haxx.se/docs/caextract.html
  • Save the file in your PHP installation folder. I am using xampp. So I saved it in C:\Installation\xampp\php\cacert.pem
  • Open your php.ini file and add this line:
    curl.cainfo="C:\Installation\xampp\php\cacert.pem"
  • Restart your Apache server and that should fix it.
Method 2:
If you are unable to edit php.ini file, there is a quick workaround.
  • Open the MailChimp API file (it's most likely named Mailchimp.php or MailChimp.class.php).
  • Look for statements starting with "curl_setopt".
  • Right below the set of "curl_setopt" statements, add this line:
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
Both methods should work but method 1 is probably more reliable.

Comments

  1. method 1 worked for me, thanks

    ReplyDelete
  2. Freaking fantastic, worked like a charm.

    Thanks!

    ReplyDelete
  3. Awesome, #2 worked for me! Thank you :)

    ReplyDelete
  4. This can be done without editing the wrapper class file.

    Just pass an argument while initializing the Mailchimp class.

    $mailchimp_obj = new Mailchimp ( 'YOUR_API_KEY', array('ssl_verifypeer' => false) );

    ReplyDelete
    Replies
    1. Haven't tried this. If this works, that's great! Thanks for sharing.

      Delete
    2. Yes, setting ssl false, worked for me. Thank you :)

      Delete
    3. Yes, setting ssl to false, worked for me. Thanks :)

      Delete
  5. Method 2 didn't work, so I tried first one for local machine - and it worked.
    Hope, it will work after deploy :)

    ReplyDelete
    Replies
    1. I got this error only when working in the localhost. In the remote server, it wasn't an issue. Let me know if yours still continue to work after the deployment.

      Delete
  6. Does anyone know how to setup the correct paths.

    All my links point to the root's www but i installed it in http://M.Y.I.P/mcapi2-php-examples/ , but the links goto http://M.Y.I.P/

    ReplyDelete
    Replies
    1. Not sure if I understand completely.
      However in your .htaccess, try this:
      RewriteEngine On
      RewriteBase /mcapi2-php-examples/

      Delete
  7. Perfect! Nr. 1 worked for me.
    Thank you very much!

    Have a nice time :-)

    ReplyDelete
  8. Thats an excellent tip. Tip 2 worked for me.

    ReplyDelete
  9. How do you fixed in wordpress because it dont have these folders you mentioned above

    ReplyDelete
  10. Thank you very much, method 2 worked for me, i just had to make a small change for the v 2.0:

    Instead:
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    Use this:
    curl_setopt($this->ch, CURLOPT_SSL_VERIFYPEER, false);

    ReplyDelete
  11. Thanks!, The second method work for me :D

    ReplyDelete
  12. non of them worked for me :(
    In Mailchimp.php there is curl_setopt($this->ch, CURLOPT_FOLLOWLOCATION, true);
    & I set FALSE but still showing:
    API call to lists/list failed: SSL certificate problem: unable to get local issuer certificate

    ReplyDelete
  13. thanks both methods worked for me

    ReplyDelete
  14. Thanks, i spent so many hours but no luck. Thank you very much!

    ReplyDelete
  15. wow It worked. Ohhh man you helped me so much. God bless you

    ReplyDelete
  16. Thanks Method 2 worked for me :)

    ReplyDelete
  17. Free SSL ought to not be used for protected payments.

    ReplyDelete

Post a Comment

Popular posts from this blog

How to resolve 'res://ieframe.dll/acr_error.htm#' error (Internet Explorer stopped working while viewing a website)

htaccess: Redirecting multiple domains to the main domain

Removing index.php in Codeigniter using XAMPP on Windows