doraemon0769 2012-05-01 14:33
浏览 54
已采纳

cURL SSL请求失败

I'm trying to work with Liveperson REST API, I use the following php code:

$authorization = "LivePerson appKey=MY_APP_KEY";
$accept = "application/xml";
$contentType = "application/xml";


$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_CAINFO, getcwd() . "C:/dev/wamp/exported.crt");

curl_setopt($ch, CURLOPT_URL, "https://dev.liveperson.net/api/account/1234?v=1");
curl_setopt($ch,CURLOPT_HTTPHEADER,array('Authorization: '.$authorization,'Accept: '.$accept,'Content-Type: '.$contentType));
curl_exec($ch);
$response = curl_getinfo( $ch );
var_export($response);
curl_close($ch);

The request fails, I already tried the following

  • enabeling openssl on php.ini
  • exporting the certificate from liveperson server and using it in my code
  • followed the instruction here

any help will be appreciated!

  • 写回答

2条回答 默认 最新

  • dsmupo6631 2012-05-01 14:45
    关注

    Try removing getcwd() from line 9 in your code. You are using fullpath "C:/dev/wamp/exported.crt", that is relative to your current working directory, this is wrong. :)

    Hope this solves it

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?