How to call in curl and set the certificates

1 post / 0 new
support@shrilifetech.com
How to call in curl and set the certificates

I am not able to send certificates in curl request, i have try to much things, my curl methods is this.

 

public function postCURLDomesticPayment($url,$data)

{

        $username = ram;

        $password = testPass;

        $x_ibm_client_id = xyz;

        $x_ibm_client_secret = secretkey;

 

        $certFile = 'aabeca4453bf475c.crt';

        $keyFile = 'aabeca4453bf475c.key';

        $pfxFile = 'aabeca4453bf475c.pfx';

        $certPassword = 'myPassword;

 

        $responseObj = new stdClass();

        $curl = curl_init();

        $headerInfo = array(

        "Content-Type: application/json",

        "Authorization: Basic ". base64_encode("$username:$password"),

        "X-IBM-Client-Id: ".$x_ibm_client_id,

        "X-IBM-Client-Secret: ".$x_ibm_client_secret

        );

        $options = array(

            CURLOPT_URL => $url,

            CURLOPT_PORT =>444,

            CURLOPT_RETURNTRANSFER => true,

            CURLOPT_TIMEOUT => 30,

            CURLOPT_ENCODING => "",

            CURLOPT_MAXREDIRS => 10,

            CURLOPT_FOLLOWLOCATION => true,

            CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,

            CURLOPT_CUSTOMREQUEST => "POST",

            CURLOPT_SSL_VERIFYPEER => true,

            CURLOPT_SSL_VERIFYHOST => '2',

            CURLOPT_CERTINFO => 1,

            CURLOPT_SSLCERT => $pfxFile,

            CURLOPT_SSLCERTTYPE =>'P12',

            CURLOPT_SSLKEY => $keyFile,

            CURLOPT_KEYPASSWD => $certPassword,

            CURLOPT_POSTFIELDS => json_encode($data),

            CURLOPT_HTTPHEADER => $headerInfo,

        );

        curl_setopt_array($curl,$options);

        $response = curl_exec($curl);

        $httpcode = curl_getinfo($curl, CURLINFO_HTTP_CODE);

        $responseObj->status = $httpcode;

        $responseObj->response = $response;

        curl_close($curl);

        return $responseObj;

}

Please help let me know the solution.