Jun 16, 2021
0
Level 2
could not load PEM client certificate, OpenSSL error for calling SOAP services in PHP
I have a wsdl API that uses from Certificate to answer. I have a certificate.cer file in base64 format I created a pem file with following commands:
1- openssl pkcs12 -export -out mycer.pfx -inkey mycer.key -in mercer.cer
2- openssl pkcs12 -in mycer.pfx -out mycer.pem
and I write following code to use it:
$curl = curl_init();
$date = "2021/02/01";
curl_setopt_array($curl, array(
CURLOPT_URL => 'url'
CURLOPT_RETURNTRANSFER => true,
CURLOPT_MAXREDIRS => 10,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_2_0,
CURLOPT_SSL_VERIFYPEER => true,
CURLOPT_SSLCERT => storage_path().'/certs/mycer.pem',
CURLOPT_SSLCERTPASSWD => '1234',
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => "<x:Envelope xmlns:x=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:tem=\"http://tempuri.org/\">
<x:Header/>
<x:Body>
<tem:GetAccountTransaction>
<tem:accountNo>123</tem:accountNo>
<tem:rowSeqPerDay>0</tem:rowSeqPerDay>
<tem:transactionDate>{$date}</tem:transactionDate>
</tem:GetAccountTransaction>
</x:Body>
</x:Envelope>",
CURLOPT_HTTPHEADER => array(
'SOAPAction: http://tempuri.org/IStatementService/GetAccountTransaction',
'Content-Type: text/soap+xml; charset=utf-8'
),
));
$response = curl_exec($curl);
curl_close($curl);
dd($response , curl_error($curl));
But I get this error:
"could not load PEM client certificate, OpenSSL error error:02001024:system library:fopen:File name too long, (no key found, wrong pass phrase, or wrong file format?)"
My question is how can I call this special api type?
Please or to participate in this conversation.