我正在做一个应该连接到RESTful webservice的php应用程序,它需要一个客户端证书。
但是当我使用php curl和客户端ceritifcate时,我遇到了分段错误。
密钥和证书文件是正确的。我在rhel 6上使用php 5.3.3。
任何帮助人员?
<?php
$url = 'https://10xxxxxxxxxxxxxxxxxx';
$data = array(xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx);
$data_string = json_encode($data);
echo($data_string);
error_reporting(E_ALL);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Accept: application/json',
'User-Agent: Apache CXF 2.6.1',
'Cache-Control: no-cache',
'Pragma: no-cache',
'Connection: keep-alive',
'Content-Length: ' . strlen($data_string))
);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_SSLKEY, '/fullpath/b.key');
curl_setopt($ch, CURLOPT_SSLCERT, '/fullpath/c.crt');
$result = curl_exec($ch);
echo(htmlentities($result));
?>