Passing .pem and .key files in cURL doesn’t work in WordPress

Based on @Mamaduka comment; the following changes resolve it:

Use plugin_dir_path() to get the filesystem directory path:

$certfile = plugin_dir_path(__FILE__) . '/clientcert.pem';
$keyfile = plugin_dir_path(__FILE__) . '/clientkey.key';

Then remove getcwd().

If you want to use it in your theme use TEMPLATEPATH

I also want to mention that using the following paths previously did not work:

WP_PLUGIN_URL . "https://wordpress.stackexchange.com/" . plugin_basename( dirname(__FILE__) ) . '/clientkey.key'

nor:

get_bloginfo('template_directory') . '/lib/cert/clientcert.pem'

nor:

'http://my-web-site.com/clientcert.pem'

Leave a Comment