我正在做一个 php 应用程序,它应该连接到需要客户端证书的 RESTful web 服务。
但是在将 php curl 与客户端证书一起使用时出现分段错误。
密钥和证书文件正确。我在 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));
?>