title: How to fix Stripe Error: Network error [errno 77]: error setting certificate verify locations
body: <p>I am attempting to use Stripe on my site but am getting the following error:</p>
  
  <pre><code>Fatal error:
      Uncaught Stripe\Error\ApiConnection: Unexpected error communicating with Stripe. If this problem persists, let us know at support@stripe.com.
      (Network error [errno 77]: error setting certificate verify locations: CAfile: CApath: /etc/ssl/certs) in /var/www/html/assets/vendor/stripe/lib/HttpClient/CurlClient.php:284
  Stack trace:
      #0 /var/www/html/assets/vendor/stripe/lib/HttpClient/CurlClient.php(241): Stripe\HttpClient\CurlClient-&gt;handleCurlError('https://api.str...', 77, 'error setting c...', 0) 
      #1 /var/www/html/assets/vendor/stripe/lib/HttpClient/CurlClient.php(203): Stripe\HttpClient\CurlClient-&gt;executeRequestWithRetries(Array, 'https://api.str...') 
      #2 /var/www/html/assets/vendor/stripe/lib/ApiRequestor.php(364): Stripe\HttpClient\CurlClient-&gt;request('post', 'https://api.str...', Array, Array, false) 
      #3 /var/www/html/assets/vendor/stripe/lib/ApiRequestor.php(96): Stripe\ApiRequestor-&gt;_requestRaw('post', '/v1/charges', Array, Array)
      #4 /var/www/html/assets/vendor/stripe/lib/ApiOperations/Request.php(5 in /var/www/html/assets/vendor/stripe/lib/HttpClient/CurlClient.php on line 284
  </code></pre>
  
  <p>I recently created a new VM on Google Compute Engine using the one-click LAMP deployment.  I also used Lets Encrypt to allow for https.  Further, I have downloaded the latest cacert.pem file and placed it in the <code>/etc/ssl/certs</code> folder.</p>
  
  <p>The certs folder has the following permissions:</p>
  
  <pre><code>drwxr-xr-x 2 root root     20480 Apr  5 14:31 certs
  </code></pre>
  
  <p>The file has the following permissions:</p>
  
  <pre><code>-rw-r--r-- 1 root root 219596 Apr  5 14:29 cacert.pem
  </code></pre>
  
  <p>I also edited the <code>php.ini</code> file to point the <code>curl.cainfo</code> and <code>openssl.cafile</code> to the pem file and restarted Apache.</p>
  
  <p>In looking at Stripe's site, it mentioned that TLS 1.2 is now required.  I have confirmed that my site is using it.  But some sample test code on Stripe's site seems to indicate that it's not seeing TLS 1.2.</p>
  
  <p>According to ssllabs.com, my site is recognized as having the TLS 1.2 protocol.</p>
  
  <p>The Stripe sample code that I added to my site to validate is:</p>
  
  <pre><code>\Stripe\Stripe::setApiKey("sk_test_BQokikJOvBiI2HlWgH4olfQ2");
      try {
          \Stripe\Charge::all();
          echo "TLS 1.2 supported, no action required.";
      } catch (\Stripe\Error\ApiConnection $e) {
          echo "TLS 1.2 is not supported. You will need to upgrade your integration.";
      }
  </code></pre>
  
  <p>I also added the following for additional version information:</p>
  
  <pre><code>echo 'PHP version: ' . phpversion() . PHP_EOL . '&lt;br/&gt;';
      echo 'cURL version: ' . curl_version()['version'] . PHP_EOL . '&lt;br/&gt;';
  
      $ch = curl_init();
      curl_setopt($ch, CURLOPT_URL, "https://www.howsmyssl.com/a/check");
      curl_setopt($ch, CURLOPT_SSLVERSION, 6);
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
      $response = curl_exec($ch);
      curl_close($ch);
  
      echo 'TLS version: ' . json_decode($response)-&gt;tls_version . PHP_EOL;
  </code></pre>
  
  <p>The result when I run it is:</p>
  
  <pre><code>============= Stripe Suggested Test Code ============
  TLS 1.2 is not supported. You will need to upgrade your integration.
  ================================================
  ==================== Version Code ===================
  PHP version: 7.0.33-0+deb9u3 
  cURL version: 7.52.1 
  TLS version: TLS 1.2 
  ================================================
  </code></pre>
  
  <p>At this point, I'm running out of ideas.  For full disclosure, I do most of my learning through Google searches and this site so any help at a hobby coder level would be appreciated.</p>