How to troubleshoot SDK issues

Here you can find some tips for handling the most frequently encountered errors delivered by Xsolla PHP SDK.
Expand all
Collapse all

How to troubleshoot the verifying certificate error

Error [curl] 77: Error setting up the location verification certificate: CAfile appears when you send a request to the Xsolla server using Pay Station SDK, e.g., when getting a token.

By default, we enable SSL-certificate verification and use the default CA bundle provided by your operating system. However, not all systems have a CA bundle on the disk. For example, Windows and OS X do not have a single common location for CA bundles.

There are several ways to resolve this problem:

  • You can disable the certificate verification when in the development environment. Use this code:

Copy
Full screen
Small screen
<?php

use Xsolla\SDK\API\XsollaClient;

$client = XsollaClient::factory(array(
    'merchant_id' => MERCHANT_ID,
    'api_key' => API_KEY
));
$client->setDefaultOption('ssl.certificate_authority', false);

Note:
You need to also test this issue in the production environment.

  • Provide a reliable certificate. Make sure the CA file exists and specify the path to it with the code below, where:
    • /path/to/file is a path to the CA file
    • ssl.certificate_authority is the CA file name

Copy
Full screen
Small screen
<?php

use Xsolla\SDK\API\XsollaClient;

$client = XsollaClient::factory(array(
    'merchant_id' => MERCHANT_ID,
    'api_key' => API_KEY
));
$сlient->setDefaultOption('ssl.certificate_authority', '/path/to/file');

In Windows the CA file can be located in the following folders:

  • C:\windows\system32\curl-ca-bundle.crt
  • C:\windows\curl-ca-bundle.crt

If there is no certificate in the specified places, you can use the certificate provided by Mozilla.

In some versions of PHP for Windows, configuring paths to certificates via code can be a problem. To resolve it, download the cacert.pem file and specify the path to it in the php.ini config file.

Copy
Full screen
Small screen
curl.cainfo=c:/cacert.pem

Hide

How to troubleshoot the authentication error

An error with the INVALID_SIGNATURE code and the Authorization header not found in Xsolla webhook request message appears if PHP-CGI for Apache doesn’t pass HTTP Basic user/pass to PHP by default. To resolve it, add the following string to the .htaccess or httpd.conf Apache config file:

Copy
Full screen
Small screen
<?php

RewriteEngine On
RewriteCond %{HTTP:Authorization} ^(.+)$
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

Hide

How to troubleshoot the invalid IP address

By default, if you use Pay Station PHP SDK, Xsolla checks the IP addresses from which the webhooks were sent. The INVALID_CLIENT_IP error code is returned in one of the following cases:

  • the webhook server was tested from a localhost in the development environment
  • your app was working in the production environment behind a proxy server, e.g., a load balancer

If you are in the development environment, turn off the IP address checking with this code:

Copy
Full screen
Small screen
<?php

use Xsolla\SDK\Webhook\WebhookServer;

$webhookServer = WebhookServer::create($callback, PROJECT_KEY);
$webhookServer->start($webhookRequest = null, $authenticateClientIp = false);

If you’re using a proxy server, choose one of the following solutions:

  • Add the reverse proxy IP address to the webhook server with the following code (the recommended way):

Copy
Full screen
Small screen
<?php

use Xsolla\SDK\Webhook\WebhookServer;
use Symfony\Component\HttpFoundation\Request;

$request = Request::createFromGlobals();
$request->setTrustedProxies(array('YOUR_PROXY_SERVER_IP_OR_CIDR'));

$webhookServer = WebhookServer::create($callback, PROJECT_KEY);
$webhookServer->start();

  • Manually add the proxy IP address to the allowlist.

Read more detailed information about working with a proxy server in the Simfony documentation.

Hide