SocalNick / orchestrate-php-client

A PHP client for Orchestrate.io
BSD 3-Clause "New" or "Revised" License
32 stars 5 forks source link

Error: Uncaught exception - SSL certificate problem #17

Closed DannyFeliz closed 9 years ago

DannyFeliz commented 9 years ago

I'm trying to follow your tutorial but when I run my code and I get this error

Fatal error: Uncaught exception 'GuzzleHttp\Ring\Exception\RingException' with message 'cURL error 60: SSL certificate problem: self signed certificate in certificate chain' in D:\Disco D\xampp\htdocs\landing-page\vendor\guzzlehttp\ringphp\src\Client\CurlFactory.php:127 Stack trace: #0 D:\Disco D\xampp\htdocs\landing-page\vendor\guzzlehttp\ringphp\src\Client\CurlFactory.php(91): GuzzleHttp\Ring\Client\CurlFactory::createErrorResponse(Array, Array, Array) #1 D:\Disco D\xampp\htdocs\landing-page\vendor\guzzlehttp\ringphp\src\Client\CurlHandler.php(96): GuzzleHttp\Ring\Client\CurlFactory::createResponse(Array, Array, Array, Array, Resource id #84) #2 D:\Disco D\xampp\htdocs\landing-page\vendor\guzzlehttp\ringphp\src\Client\CurlHandler.php(68): GuzzleHttp\Ring\Client\CurlHandler->_invokeAsArray(Array) #3 D:\Disco D\xampp\htdocs\landing-page\vendor\guzzlehttp\ringphp\src\Client\Middleware.php(54): GuzzleHttp\Ring\Client\CurlHandler->__invoke(Array) #4 D:\Disco D\xampp\htdocs\landing-page\vendor\guzzlehttp\ringphp\src\Client\Mi in D:\Disco D\xampp\htdocs\landing-page\vendor\guzzlehttp\guzzle\src\Exception\RequestException.php on line 51

And this is my code

use SocalNick\Orchestrate\Client; use SocalNick\Orchestrate\KvPutOperation;

$client = new Client('MY_API_KEY");

$userId = rand(1, 100); $data = [ "name" => "Eduardo", "age" => 25 ];

$kvPutOp = new KvPutOperation("users", userId, json_encode($data)); $obj = $client->execute($kvPutOp);

var_dump($obj->getRef());

Could you please help me with this error? I had been googling about this error and they are talking about the certficate and of course this is the problem but I can't figure out how to set the certificate but nothing works until now, i was following this issue but this is other library.

SocalNick commented 9 years ago

Do you know if you have cURL on your computer? I think it is commonly installed on Mac / Linux, but not Windows. If cURL isn't available, Guzzle will fall back to it's own HTTP client and possibly not use your system set of root certificates.

Try installing cURL for your version of Windows, this may help: http://support.gnip.com/articles/curl-on-win7.html

DannyFeliz commented 9 years ago

@SocalNick I have cURL on my computer and if I go to C:\Program Files\cURL\bin you can see the certificate (curl-ca-bundle.crt) certificate so I don't know what's wrong curl

SocalNick commented 9 years ago

Can you make cURL requests to Orchestrate directly?

curl -i "https://api.orchestrate.io/v0/$collection?force=true" \
  -XDELETE \
  -u "$api_key:"
SocalNick commented 9 years ago

Sorry, that was a delete, try:

curl -i "https://api.orchestrate.io/v0/$collection"   -u "$api_key:"
DannyFeliz commented 9 years ago

Yes @SocalNick , I get results if from the command line I run any request. api

SocalNick commented 9 years ago

It's likely that XAMPP either isn't using that curl or isn't using correct CA info. Try this solution:

http://stackoverflow.com/a/16495053

DannyFeliz commented 9 years ago

Yes @SocalNick you were right It was a problem of XAMPP I just had to add curl.cainfo = "PATH_TO/cacert.pem" at the end of the php.ini file of XAMPP, located in XAMMP/PHP/php.ini

Thank you man! :smile: :sunglasses:

SocalNick commented 9 years ago

Glad we figured it out!

myadav2005 commented 6 years ago

It's easy to fix for (php 5.3.7 or higher) - Download a list file with an up-to-date certificate authorities, and add this setting to your php.ini

It works as below for me by adding full path of certificate file.

curl.cainfo =E:\xampp\php\cacert.pem