Paypal Access - SSL certificate: unable to get local issuer certificate

Paypal Access - SSL certificate: unable to get local issuer certificate

  1. Blog
  2. 15 November 2026
  3. 3 min read

Stefan Bogdanescu

Founder & Senior Architect

Resolving the "Unable to Get Local Issuer Certificate" Error in PayPal API Requests

When attempting to authenticate with the PayPal Sandbox environment via cURL and PHP, encountering an SSL certificate problem: unable to get local issuer certificate is a common stumbling block. The endpoint in question, https://www.sandbox.paypal.com/webapps/auth/protocol/openidconnect/v1/tokenservice, explicitly requires HTTPS. This means that SSL/TLS verification is not optional; it is a fundamental requirement for the connection to be established securely.

The error message indicates that your PHP environment cannot validate the chain of trust leading back to a trusted root Certificate Authority (CA). In a properly configured system, cURL attempts to verify the server's certificate against the list of trusted CAs stored in your operating system or within the cacert.pem file bundled with OpenSSL. If this verification fails, cURL halts the request and returns an error, regardless of whether you are trying to retrieve a simple email address or a full OAuth token.

Why the Error Occurs

The phrase "unable to get local issuer certificate" specifically points to a broken chain of trust. This usually happens in one of two scenarios:

  1. Missing CA Bundle: Your PHP installation lacks access to the current list of trusted root certificates. Older PHP versions or minimal Docker images often ship with an outdated ca-bundle.crt that no longer contains the necessary keys for modern SSL chains.
  2. Certificate Verification Disabled: The cURL option CURLOPT_SSL_VERIFYPEER is set to false (or not explicitly set to true, allowing a default behavior that might be unsafe). However, the error message shown in your logs suggests that peer verification is actually being attempted, but the local store of trusted certificates is insufficient.

You do not need SSL just to "get user email." Any communication with PayPal's infrastructure over HTTPS mandates encryption and certificate validation. Attempting to bypass this by disabling SSL verification (setting CURLOPT_SSL_VERIFYPEER to 0) is a significant security anti-pattern. It leaves your application vulnerable to Man-in-the-Middle attacks, where an attacker could intercept your credentials or inject malicious payloads into the response.

How to Fix It in PHP

The most robust and secure solution is to ensure that your cURL session has access to the correct CA bundle. In a typical Linux environment, this file is often located at /etc/ssl/certs/ca-certificates.crt. If you are running on Windows or using a container with a stripped-down OpenSSL installation, this path may be missing entirely.

You can resolve this by explicitly pointing cURL to your system's CA bundle:

$caPath = '/etc/ssl/certs/ca-certificates.crt'; // Adjust path based on OS
$options = array(
    CURLOPT_URL => $url,
    CURLOPT_POST => 1,
    CURLOPT_VERBOSE => 0, // Verbose is useful for debugging, but not required for production logic
    CURLOPT_POSTFIELDS => $postvals,
    CURLOPT_RETURNTRANSFER => 1,
    CURLOPT_SSLVERSION => 3,
    CURLOPT_SSL_VERIFYPEER => true,
    CURLOPT_CAINFO => $caPath, // Explicitly set the CA bundle
);

curl_setopt_array($ch, $options);

$response = curl_exec($ch); 
if (curl_errno($ch) == 60) {
    echo "SSL certificate problem: unable to get local issuer certificate\n";
} else {
    echo curl_error($ch);
}

Alternatively, if you cannot modify the CURLOPT_CAINFO path or do not want to hardcode it, you can copy the contents of your system's CA bundle to a known location (e.g., the project root) and reference that relative path. For Docker environments, this is often solved by installing the ca-certificates package in the base image.

Trade-offs and Best Practices

While some developers might be tempted to ignore the error to get the code running immediately, doing so compromises the integrity of your API integration. PayPal's Sandbox environment rotates its certificates regularly; relying on an old or missing CA bundle will inevitably break future requests.

If you are using a framework like Laravel, you can leverage its HTTP client or configure cURL globally within your application configuration to ensure CURLOPT_CAINFO is always resolved correctly across all requests. Always prioritize explicit certificate validation over convenience unless you have a strictly isolated, air-gapped network where SSL termination is handled by a trusted internal proxy (which is not the case with public APIs like PayPal).

By ensuring your local environment matches the standards of the public internet—specifically regarding root certificates—you eliminate this class of errors and secure your integration against potential man-in-the-middle threats.

Our network