I got support from my API providers that pointed out something missing from my approach. For their gateway, I needed to download a private key, a public key and a password that protects these keys in a curl request. The solution is as follows:
/*ssl crts*/ $twpg_cert_file = "/etc/apache2/ssl/m4/mydomain.com.crt"; $twpg_key_file = "/etc/apache2/ssl/m4/mydomain.com.key"; $twpg_key_password = ''; /*ssl crts*/ $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $requestUrl); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_TIMEOUT, 60000); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_data);//My post data curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); curl_setopt($ch, CURLOPT_SSLCERT, $twpg_cert_file); curl_setopt($ch, CURLOPT_SSLKEY, $twpg_key_file); curl_setopt($ch, CURLOPT_SSLKEYPASSWD, $twpg_key_password); curl_setopt($ch, CURLOPT_CERTINFO, 1); $headers = []; array_push($headers, 'Content-Type: text/xml;charset=UTF-8'); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); $content = trim(curl_exec($ch)); echo nl.'response of server: '; var_dump($content); echo nl.nl.'curl info: '; var_dump(curl_getinfo($ch)); echo nl.nl.'curl error number: '; var_dump(curl_errno($ch)); echo nl.nl.'curl error info: '; var_dump(curl_error($ch)); curl_close($ch);
Now everything works as expected.
source share