I keep getting the error which calling an API locally, works fine on my server:
cURL error 60: SSL certificate problem: unable to get local issuer
certificate
Is there a way to stop this exception from showing locally?
Here's my code, ignore the () as this is variable info:
public function testCheck($domains){
$client = new Client();
$res = $client->request('GET', 'https://api.namecheap.com/xml.response?ApiUser=(username)&ApiKey=(apikey)&UserName(username)&ClientIp=(ip)&Command=namecheap.domains.check&DomainList=' . $domains);
$data = json_decode($res->getBody());
dd($data);
}
Is there a way to stop this exception from showing locally so I can carry on testing?
If you are testing locally you can disable the SSL verification:
// Disable validation entirely
$client->request('GET', '/', ['verify' => false]);
See the docs for more information:
http://guzzle.readthedocs.io/en/latest/request-options.html#verify-option
However you should not use this for anything else than testing, in normal cases you should use a certificate and verify this certificate properly.
Related
I used OpenSSL to generate an SSL Certificate for my localhost, but the self-signed certificate seems to be causing problems when authenticating with Podio:
Fatal error: Uncaught PodioConnectionError: Connection to Podio API failed: [60] SSL certificate problem: self signed certificate in certificate chain
I tried downloading cacert.pem and adding it to my php.ini file curl.cainfo=<path-to>cacert.pem, but after restarting the server, I still get the same error.
With some other library's I've had to set CURLOPT_SSL_VERIFYPEER, but I'm not sure how I would do that anyway using the Podio PHP client library...
Any tips on debugging this error?
I found out how to set CURLOPT_SSL_VERIFYPEER => false when using the Podio PHP client library:
$options = array('curl_options' => array(CURLOPT_SSL_VERIFYPEER => false));
Podio::setup($client_id, $client_secret, $options);
Now I just have to remember to remove this in production...
I'm using GuzzHttp in my laravel project to post some data to an API. In my local enviroment I have to to create my client with the cacert.pem file verification like this:
$client = new \GuzzleHttp\Client(['verify' => 'C:\wamp64\bin\php\php7.2.14\cacert.pem']);
But I can't do so on my shared hosting. So, removing that verification:
$client = new \GuzzleHttp\Client();
Results on an internal server error:
[2019-06-11 15:17:10] local.ERROR: GuzzleHttp\Exception\ServerException: Server error: `POST https://pruebas2.mayoristaseguridad.es/tiendaseguridad/02-ConectorLaravelPrestashop/ConectorCategorias.php` resulted in a `500 Internal Server Error` response in /home/admin/web/iberoseguridad.eu/public_html/csv_products/vendor/guzzle/guzzlehttp/guzzle/src/Exception/RequestException.php:113
Is there a way to fix this error?
Not sure if this will help, here it goes anyways
// Disable validation entirely (don't do this!).
$client->request('GET', '/', ['verify' => false]);
Guzzle verify api
This ended up being a remote server error, not mine. I just had to communicate that error with the server's maintainer and now it works just fine.
I am getting a PHP curl error when posting payments after moving our PHP code from a linux server to a new windows server. The error is below:
error #60: SSL certificate problem: unable to get local issuer certificate.
To try and fix the situation I commented out the below line but still get the same error:
curl_setopt($curl_request, CURLOPT_CAINFO, dirname(dirname(__FILE__)) . '/ssl/cert.pem');
I am trying to connect to Azure API.I am kinda new to this.I am using the php code given in the samples.I am using wamp on my local server.
I have configured SSL on localhost so that I am able to open https://www.wamphelpers.dev/faces.php
However I keep getting the error below:
Failed to enable crypto stream_socket_client(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed in <b>C:\wamp\bin\php\php5.5.12\pear\HTTP\Request2\Adapter\Socket.php
My code is below:
<?php
// This sample uses the Apache HTTP client from HTTP Components (http://hc.apache.org/httpcomponents-client-ga/)
require_once 'HTTP/Request2.php';
$request = new Http_Request2('https://southeastasia.api.cognitive.microsoft.com/face/v1.0/persongroups/{personGroupId}');
$url = $request->getUrl();
$headers = array(
// Request headers
'Content-Type' => 'application/json',
'Ocp-Apim-Subscription-Key' => 'keygoeshere',
);
$request->setHeader($headers);
$parameters = array(
// Request parameters
'personGroupId' => 'heroes',
);
$url->setQueryVariables($parameters);
$request->setMethod(HTTP_Request2::METHOD_PUT);
// Request body
$request->setBody("heroes");
try
{
$response = $request->send();
echo $response->getBody();
}
catch (HttpException $ex)
{
echo $ex;
}
?>
From what I have read it is a certificate issue and I have checked my php settings and made sure it is pointing to the right file.
out is below:
OPENSSL_CONF C:\OpenSSL-Win32\bin\openssl.cfg
I read a little and it seems I can disable SSL check in PHP using the context_options by making verify peer to false.
But how do I use it to hit the URL.
Below is the link for the API reference.
Just point HTTP/Request2 to use a CA bundle, as instructed here.
ssl_cafile
Certificate Authority file to verify the peer with (use when ssl_verify_peer is TRUE). You can use e.g. cURL's CA Extract tool to get such a file.
$request = new HTTP_Request2();
$request->setConfig(array(
'ssl_cafile' => '/path/to/cacert.pem'
));
The remote certificate can now be verified against the complete chain.
I'm getting following error while trying to implement google authentication in my local website.
Fatal error: Uncaught exception 'GuzzleHttp\Exception\RequestException' with message 'cURL error 60: SSL certificate problem: unable to get local issuer certificate (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)' in C:\xampp\htdocs\social_login_example\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php:187.
I surfed the given URL but it didn't provide me any useful information to eliminate the error. What is this error and what can I do to remove it.
I'm using chrome web browser and PHP-5.6.8
$guzzleClient = new \GuzzleHttp\Client(['verify' => false]);
Guzzle version 6