gpt4 book ai didi

PHP Curl 证书信息为空

转载 作者:太空宇宙 更新时间:2023-11-03 12:57:18 25 4
gpt4 key购买 nike

我有一个 PHP 脚本,它向网络服务发出 curl 请求。该请求是从我安装了 SSL 的服务器发出的,我发送请求的 Web 服务也有一个 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);

我得到的调试信息如下:

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

“certinfo”为空数组是否正常?如果不是为什么它是空的。谢谢。

最佳答案

您可能需要设置以下选项以填充“certinfo”

curl_setopt($ch, CURLOPT_CERTINFO, 1);

关于PHP Curl 证书信息为空,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45537443/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com