How to solve the error "could not load PEM client certificate, OpenSSL error:02001003:system library:fopen:No such process"? How to solve the error "could not load PEM client certificate, OpenSSL error:02001003:system library:fopen:No such process"? curl curl

How to solve the error "could not load PEM client certificate, OpenSSL error:02001003:system library:fopen:No such process"?


For a SSL verification you need a cert in pem format, it's associated private key (in openssl format) and the root certificate of the certification authoritity that signed your certificate in pem format.

Check this full sample :

PHP:path of CURLOPT_SSLCERT

The error message is not really clear if your are not informed but it say it :

could not load PEM client certificate, OpenSSL error error:02001003:system library:fopen:No such process, (no key found, wrong pass phrase, or wrong file format?)

Regards,


i bet the error will be easier to understand if you change it to

$ch = curl_init();curl_setopt($ch, CURLOPT_URL, 'my_addr');curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);$pem=realpath("myfile.pem");if(!$pem || !is_readable($pem)){    die("error: myfile.pem is not readable! realpath: \"{$pem}\" - working dir: \"".getcwd()."\" effective user: ".print_r(posix_getpwuid(posix_geteuid()),true));}curl_setopt($ch, CURLOPT_SSLCERT, $pem);

.. most likely the pem file is not readable by the account that php is running under (eg if you created the file as root and the owner is root:root and the permissions is a-r and php is running under the account www-data), another explanation is that the file plain out doesn't exist - yet another explanation is that you run chdir() prior to running curl_exec(), and since you're using a relative filepath, the relative path is no longer valid when running curl_exec() (but using realpath(), as i did above, solves this last issue)