Bug #69035 [Opn->Nab]: curl error setting CURLOPT_CAINFO .crt file inside PHAR

From: Date: Thu, 12 Feb 2015 08:01:54 +0000
Subject: Bug #69035 [Opn->Nab]: curl error setting CURLOPT_CAINFO .crt file inside PHAR
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-190603@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=69035&edit=1 ID: 69035 Updated by: requinix@php.net Reported by: sebastian at phpbu dot de Summary: curl error setting CURLOPT_CAINFO .crt file inside PHAR -Status: Open +Status: Not a bug Type: Bug Package: cURL related Operating System: Linux (Debian Wheezy) PHP Version: 5.6.5 Block user comment: N Private report: N New Comment: cURL is a third-party library. It doesn't know about things like phars, and unfortunately there's no way to pass it the certificate as a string. However you can dump the contents of the cert to a temp file, run your cURL operations, then delete the file. Previous Comments: ------------------------------------------------------------------------ [2015-02-12 07:44:29] sebastian at phpbu dot de Description: ------------ The Error occures if you create a PHAR with a .crt file in it. Setting the CURLOPT_CAINFO option and linking a .crt file within the phar leads to an error like this Curl failed to exec error setting certificate verify locations: CAfile: phar:///tmp/my.phar/demo/ca.crt CApath: /etc/ssl/certs ' in phar:///tmp/my.phar/demo/example.php:9 Setting CURLOPT_CAPATH to __DIR__ doesn't help either. Dumping the .crt file to stdOut works in phar mode so the file is there. Not compiled to phar the code works fine. Using: PHP 5.6.5 curl 7.26.0 (x86_64-pc-linux-gnu) libcurl/7.26.0 OpenSSL/1.0.1e zlib/1.2.7 libidn/1.25 libssh2/1.4.2 librtmp/2.3 Test script: --------------- <?php // curl setup $handle = curl_init(); $caFile = __DIR__ . '/ca.crt'; // check for crt file just to make sure its in the phar if (!is_file($caFile)) { throw new Exception("Failed to load ca certificate"); } curl_setopt($handle, CURLOPT_CAINFO, $caFile); // optionaly use this as well //curl_setopt($handle, CURLOPT_CAPATH, __DIR__); // make phar file containing this and a .crt file // contents of .crt doesn't matter for demonstration Expected result: ---------------- In a PHAR I want to link curl to .crt files i provide within the phar. Actual result: -------------- Curl can't access the .crt file within the phar Curl failed to exec error setting certificate verify locations: CAfile: phar:///tmp/my.phar/demo/ca.crt ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=69035&edit=1

« previous php.bugs (#190603) next »