title: cURL in PHP does not connect when run from dev server
body: <p>I am implementing the persona login system (from Mozilla). On my development machine I can not make a connection, using cURL to the authentication server. At least so it seems.</p>
  
  <p>The very same script does run from CLI.</p>
  
  <p><strong>UPDATE</strong>: I get this error, from *curl_error()*:</p>
  
  <pre><code>A PKCS #11 module returned CKR_DEVICE_ERROR,
  indicating that a problem has occurred with the token or slot.
  </code></pre>
  
  <p>The cURL PHP module is installed and does support https</p>
  
  <p>Here is a test script:</p>
  
  <p><a href="https://github.com/itpastorn/webbteknik/blob/master/website/html/curl-test.php" rel="nofollow">Also on GitHub</a></p>
  
  <pre class="lang-php prettyprint-override"><code>&lt;?php
  /**
   * Testing curl and persona
   *
   * Currently a connection is made when running from the CLI,
   * but not when accessed via web
   * Various options have been tried, but make no difference
   */
  
  echo "&lt;pre&gt;\n";
  
  $data = new StdClass();
  $data-&gt;assertion = "foo";
  $data-&gt;audience = "http://localhost";
  
  // Do curl
  $url = 'https://verifier.login.persona.org/verify';
  $ch = curl_init();
  curl_setopt_array($ch, array(
      CURLOPT_URL            =&gt; $url,
      CURLOPT_POST           =&gt; true,
      CURLOPT_POSTFIELDS     =&gt; json_encode($data),
      CURLOPT_HEADER         =&gt; false,
      CURLOPT_RETURNTRANSFER =&gt; true,
      /*
      CURLOPT_SSL_VERIFYPEER =&gt; true,
      CURLOPT_SSL_VERIFYHOST =&gt; 2,
      CURLOPT_FOLLOWLOCATION =&gt; false,
      CURLINFO_HEADER_OUT    =&gt; true,
      CURLOPT_CAINFO         =&gt; '/etc/ssl/certs/ca-bundle.crt',
      */
      CURLOPT_HTTPHEADER =&gt; array('Content-Type: application/json')
  ));
  curl_setopt($ch, CURLINFO_HEADER_OUT, true);
  echo "EXEC now\n\n";
  $response = curl_exec($ch);
  $info = curl_getinfo($ch);
  foreach ($info as $ki =&gt; $ii) {
      if ( is_array($ii) ) {
          $ii = "(array)";
      }
      echo $ki . " =&gt; " . $ii . "\n";
  }
  curl_close($ch);
  
  // Check response
  if ( empty($response) ) {
      header("HTTP/1.0 401 Authentication is possible but has failed");
      echo 'Response is empty - assertion failed: ';
      echo '{"reason" : "Assertion failed, verifying server returned empty content"}';
      exit;
  }
  
  //$response = json_decode($response);
  echo 'Response decoded: ' . $response . "\n\n";
  </code></pre>
  
  <p>Output when run from CLI:</p>
  
  <pre><code>url =&gt; https://verifier.login.persona.org/verify
  content_type =&gt; application/json; charset=utf-8
  http_code =&gt; 200
  header_size =&gt; 191
  request_size =&gt; 175
  etc
  </code></pre>
  
  <p>Output when run from the server</p>
  
  <pre><code>url =&gt; https://verifier.login.persona.org/verify
  content_type =&gt; 
  http_code =&gt; 0
  header_size =&gt; 0
  request_size =&gt; 0
  etc
  </code></pre>
  
  <p>I am running Fedora Linux</p>