cURL命令行到PHP


cURL command line to PHP

我必须使用自签名证书从PHP向安全的https服务器发出请求。我在cURL中有一个工作命令行,但有很多问题将其转换为正确和工作的PHP选项。

cURL命令如下:

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

谁能给我一些提示如何使用这个正确的方式在PHP?

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');