PHP cURL - >下载带有证书和密码的文件

I have a cert file "cert.p12" and a password for this cert "yxc123yxc". With this I can authenticate to a website do download a xml file.

how can I do this in php? Tried it like this, but "$response" is FALSE.

$cert = "cert.p12";
$pass = "yxc123yxc";
$url  = "https://url.to.download";

$curlhandle = curl_init();

curl_setopt($curlhandle, CURLOPT_URL, $url);
#curl_setopt($curlhandle, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curlhandle, CURLOPT_PORT , 443); 
curl_setopt($curlhandle, CURLOPT_SSLVERSION, 3);
curl_setopt($curlhandle, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($curlhandle, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($curlhandle, CURLOPT_SSLCERT, getcwd() . $cert);
curl_setopt($curlhandle, CURLOPT_SSLCERTPASSWD, $cert);
$response = curl_exec($curlhandle);

I guess there is wrong path to the certificate, since PHP function getcwd return path without an ending slash. Therefore your path to the certificate probably looks like this:

/var/www/website/directorycert.p12

Also it's absolutely essential for programming to know how to debug your programs. Always use functions, which return you error codes and messages of operation you are trying to debug. Also print values of variables to see, if they contain what you expect.

You can also use some debugger (for PHP there is for example one called Xdebug). If you connect your IDE with that debugger you don't have to print value of variables manually, you can step through your scripts etc.

just added

curl_setopt($curlhandle, CURLOPT_SSLCERTTYPE, "P12"); 

to the php Code

=> curl_error: SSL certificate problem, verify that the CA cert is OK. Details: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed