4

I'm messing with parse (parse.com) and when I run the following I get a fatal error. The code I am running is taken directly from the parse.com intro to the PHP SDK.

I am running XAMPP on Windows 10.

Do I need to run my scripts through https or am I really missing some SSL certs somewhere? How do I get it to work?

Error:

Fatal error:  Uncaught exception 'Parse\ParseException' with message 'SSL certificate problem: unable to get local issuer certificate' in C:\xampp\htdocs\project\assets\php\vendor\parse\php-sdk\src\Parse\ParseClient.php:284
Stack trace:
#0 C:\xampp\htdocs\project\assets\php\vendor\parse\php-sdk\src\Parse\ParseObject.php(1037): Parse\ParseClient::_request('POST', '/1/classes/Test...', NULL, '{"foo":"bar"}', false)
#1 C:\xampp\htdocs\project\assets\php\vendor\parse\php-sdk\src\Parse\ParseObject.php(947): Parse\ParseObject::deepSave(Object(Parse\ParseObject), false)
#2 C:\xampp\htdocs\project\assets\php\test.php(15): Parse\ParseObject->save()
#3 {main}
  thrown in C:\xampp\htdocs\project\assets\php\vendor\parse\php-sdk\src\Parse\ParseClient.php on line 284

And the PHP snippet:

require("./vendor/autoload.php");

use Parse\ParseClient;

ParseClient::initialize('secret', 'reallysecret', 'ubersecret');

use Parse\ParseObject;

$testObject = ParseObject::create("TestObject");
$testObject->set("foo", "bar");
$testObject->save();
Brian Emilius
  • 717
  • 1
  • 8
  • 31

1 Answers1

5

There are many duplicate questions to this and some slightly different answers.

It's not a parse.com issue, but your local PHP is not configured correctly.

One is to disable curl's SSL verification, which is bad. The other is to set your correct certificate path in php.ini.

You can download http://curl.haxx.se/ca/cacert.pem to cacert.pem file. And in your php.ini set

curl.cainfo = "c:/youroflder/cacert.pem"

this cacert.pem file is not guaranteed to be safe, but you can generate your own using different tools.

Helpful answer: How can I set CURLOPT_CAINFO globally for PHP on Windows?

Community
  • 1
  • 1
Daniel W.
  • 31,164
  • 13
  • 93
  • 151