title: PHP7 + curl (SSL/TLS) gives 502 Bad Gateway
body: <p>I am developing a webpage that uses the Dropbox SDK to do some things. Most of this happens through the CLI but one particular thing must be done in the browser. I stumbled across an interesting issue, though.</p>
  
  <pre><code>$dbxClient = new dbx\Client($accountToken, 'xxx/' . VERSION);
  $folderMetadata = $dbxClient-&gt;getMetadataWithChildren("/");
  </code></pre>
  
  <p>Running this code works just fine in CLI. Running it in the browser however gives me a 502. Being baffled I started up xdebug and traced where the problem appears. I found out, that Dropbox' curl-call was causing it so I wrote a small example script to see, if curl works at all. <strong>It does not.</strong></p>
  
  <pre><code>&lt;?php
      $ch = curl_init(); 
      curl_setopt($ch, CURLOPT_URL, "https://example.com"); 
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
      $output = curl_exec($ch); 
  
      curl_close($ch);
      echo $output;
  </code></pre>
  
  <p>Running this code in a browser gives a 502 instantly. If I remove https:// or make it a http:// (or run it in CLI) it works, though. The problem seems to be in PHP7 + curl + SSL. Adding <code>curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);</code> does NOT work.</p>
  
  <p>What can I do to find out, why this happens and how I can solve it?</p>
  
  <p><strong>System Infos:</strong></p>
  
  <ul>
  <li>OS X 10.11.2</li>
  <li>nginx 1.8.0, installed via homebrew</li>
  <li>PHP 7.0.3, installed via homebrew</li>
  <li>curl 7.43.0, installed via homebrew</li>
  <li>OpenSSL 1.0.2f, installed via homebrew</li>
  </ul>