donglingsai2880 2017-08-06 23:03
浏览 329
已采纳

PHP Curl certinfo为空

I have a script in PHP that does a curl request to a webservice. The request is made from my server that has an SSL installed and the webservice I send request too has also an SSL.

 $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, "https://webservice.com?wsdl");
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_TIMEOUT, 60000);
        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $data);//My post data
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
        curl_setopt($ch, CURLOPT_CAINFO, "../cacerts.pem");
        curl_setopt($ch, CURLOPT_CAPATH, "../cacerts.pem");
        $headers = [];
        array_push($headers, 'Content-Type: text/xml;charset=UTF-8');
        array_push($headers, 'SoapAction: *');
        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
        $content = trim(curl_exec($ch));
        var_dump($content);
        var_dump(curl_getinfo($ch));
        var_dump(curl_errno($ch));
        var_dump(curl_error($ch));
        curl_close($ch);

The debug info I get is as bellow:

array (size=26)
  'url' => string 'https://webservice.com?wsdl' (length=42)
  'content_type' => string 'text/xml;charset=utf-8' (length=22)
  'http_code' => int 200
  'header_size' => int 165
  'request_size' => int 901
  'filetime' => int -1
  'ssl_verify_result' => int 0
  'redirect_count' => int 0
  'total_time' => float 1.469
  'namelookup_time' => float 0.25
  'connect_time' => float 0.688
  'pretransfer_time' => float 1.188
  'size_upload' => float 632
  'size_download' => float 536
  'speed_download' => float 364
  'speed_upload' => float 430
  'download_content_length' => float 536
  'upload_content_length' => float 632
  'starttransfer_time' => float 1.469
  'redirect_time' => float 0
  'redirect_url' => string '' (length=0)
  'primary_ip' => string 'xxx.xxx.xxx.xxx' (length=15)
  'certinfo' => 
    array (size=0)
      empty
  'primary_port' => int 443
  'local_ip' => string 'xx.xx.xx.x' (length=10)
  'local_port' => int 61993

Is it normal that the "certinfo" is an empty array? If not why is it empty. Thanks.

  • 写回答

1条回答 默认 最新

  • dongwei1263 2017-08-06 23:18
    关注

    You may need to set the following option to have "certinfo" populated

    curl_setopt($ch, CURLOPT_CERTINFO, 1);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?