user982637
user982637

Reputation: 11

cURL command line to PHP

I have to make a request from PHP to a secure https server with a self-signed certificate. I have a working command line in cURL but have a lot of problems converting it to the correct and working PHP options.

The working cURL command is this:

curl --cacert cert.pem
     --key cert.key
     --cert cert.crt
     --header 'content-type: text/xml'
     -X POST
     --data @ftit-request.xml https://serverip/dip/DipWebservice > outputfile

Can someone give me some hints on how to use this the correct way in PHP?

Upvotes: 1

Views: 2391

Answers (1)

TROODON
TROODON

Reputation: 1175

http://php.net/manual/en/book.curl.php

curl_setopt($ch, CURLOPT_VERBOSE, '1');
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, '1');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, '1');
curl_setopt($ch, CURLOPT_CAINFO,  getcwd().'/cert/ca.crt');
curl_setopt($ch, CURLOPT_SSLCERT, getcwd().'/cert/mycert.pem');
curl_setopt($ch, CURLOPT_SSLCERTPASSWD, 'password');

Upvotes: 1

Related Questions