title: Guzzle curl error 51 in PHPUnit context
body: <p>I have a Laravel app that uses a web service to validate a field, the REST call goes through Guzzle over HTTPS. When I post a form through the browser, everything goes fine. When I run the same through phpunit as a test, Guzzle fails with:</p>
  
  <p><code>exception 'GuzzleHttp\Exception\RequestException' with message 'cURL error 51: SSL: certificate verification failed (result: 5)</code></p>
  
  <p><strong>What I tried:</strong></p>
  
  <p>1- Before Guzzle I used straight up curl which gave the same behaviour. I tried setting the cacert explicitly in the code with <code>curl_setopt($curl, CURLOPT_CAINFO, '/path/to/cacert.pem');</code> and that did nothing  </p>
  
  <p>2- I tried (same result) pointing Guzzle to the cacert with  </p>
  
  <pre><code>$response = $client-&gt;request('GET', $url, [
      'auth' =&gt; ['user', 'pass'],
      'verify' =&gt; '/path/to/cacert.pem'
  ]);
  </code></pre>
  
  <p>3- phpinfo says Apache is using its local curl and command line php uses a different one so I symlinked to the Apache version, same result</p>
  
  <p>4- Both curl.cainfo and openssl.cainfo are set  </p>
  
  <p>5- <code>/usr/local/etc/openssl/cert.pem</code> exists  </p>
  
  <p>6- passing <code>-d openssl.cainfo</code> to phpunit on the command line does nothing</p>
  
  <p><strong>Code:</strong></p>
  
  <pre><code>private function curl_rest_call($url){
  
      // $curl = curl_init() ;
  
      // curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
      // curl_setopt($curl, CURLOPT_USERPWD, "user:pass");
  
      // curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, true);
      // curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2);
      // curl_setopt($curl, CURLOPT_CAINFO, '/path/to/cacert.pem');
  
      // curl_setopt($curl, CURLOPT_URL, $url);
      // curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
  
      // $rest = curl_exec($curl);
      // $httpStatus = curl_getinfo($curl, CURLINFO_HTTP_CODE);
  
      // curl_close($curl);
      // $result = json_decode($rest) ;
  
      // $result-&gt;status = $httpStatus ;
  
      // return $result ;
  
      $client = new Guzzle();
      $response = $client-&gt;request('GET', $url, [
          'auth' =&gt; ['user', 'pass'],
          'verify' =&gt; '/path/to/cacert.pem'
      ]);
  
      $result = json_decode($response-&gt;getBody()-&gt;getContents()) ;
      $result-&gt;status = $response-&gt;getStatusCode() ;
  
      return $result ;
  
  }
  </code></pre>
  
  <p><strong>Test:</strong></p>
  
  <pre><code>public function testSuccessfulSignup(){
  
      $this-&gt;visit('/free-software')
          -&gt;type('test@mail.com', 'mail')
          -&gt;type('Philip', 'first_name')
          -&gt;type('Fry', 'last_name')
          -&gt;select('Freelancer', 'profile')
          -&gt;type('Other', 'industry')
          -&gt;select('Canada', 'country')
          -&gt;type('(514) 278-8666', 'phone_number')
          -&gt;press('Try Harmony Now!')
          -&gt;seePageIs('/success');
  }
  </code></pre>