【问题标题】:curl_getinfo($ch, CURLINFO_CERTINFO) is emptycurl_getinfo($ch, CURLINFO_CERTINFO) 为空
【发布时间】:2019-02-21 20:57:23
【问题描述】:

我有来自IUS 存储库的 PHP 7.2,但默认 PHP (CentOS 7.x) 上的行为相同。

代码:

$domain = "google.com";

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://' . $domain);
curl_setopt($ch, CURLOPT_CERTINFO, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_NOBODY, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_VERBOSE, 1);

curl_exec($ch);
$certInfo = curl_getinfo($ch, CURLINFO_CERTINFO);

curl_close($ch);

变量 $certInfo 为空。我已经用https://www.howsmyssl.com/a/check 测试了 curl,它支持 TLS 1.2。

OpenSSL 1.0.2k-fips
cURL support => enabled
cURL Information => 7.29.0
Age => 3
Features
AsynchDNS => Yes
CharConv => No
Debug => No
GSS-Negotiate => Yes
IDN => Yes
IPv6 => Yes
krb4 => No
Largefile => Yes
libz => Yes
NTLM => Yes
NTLMWB => Yes
SPNEGO => No
SSL => Yes
SSPI => No
TLS-SRP => No
Protocols => dict, file, ftp, ftps, gopher, http, https, imap, imaps, ldap, ldaps, pop3, pop3s, rtsp, scp, sftp, smtp, smtps, telnet, tftp
Host => x86_64-redhat-linux-gnu
SSL Version => NSS/3.36
ZLib Version => 1.2.7
libSSH Version => libssh2/1.4.3

怎么了?卷曲?打开ssl? nss?

【问题讨论】:

  • 您是否尝试过除 goggle 以外的其他域?

标签: php ssl curl


【解决方案1】:

试试这个:(更新域)

$domain = "www.google.com";

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://' . $domain);
curl_setopt($ch, CURLOPT_CERTINFO, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_NOBODY, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_VERBOSE, 1);

curl_exec($ch);
$certInfo = curl_getinfo($ch, CURLINFO_CERTINFO);

curl_close($ch);

【讨论】:

    【解决方案2】:

    要解决此问题,您需要将 curl 和 libcurl 更新到较新的版本,例如 7.42.0。

    在 7.42.0 中修复 - 2015 年 4 月 22 日

    Changes:
    
        openssl: show the cipher selection to use in verbose text
        gtls: implement CURLOPT_CERTINFO
        add CURLOPT_SSL_FALSESTART option (darwinssl and NSS)
        curl: add --false-start option
        add CURLOPT_PATH_AS_IS
        curl: add --path-as-is option
        curl: create output file on successful download of an empty file
    

    对于 CentOS 7.x:

    7.34 bugfix ->  NSS: support for CERTINFO feature
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-05-16
      • 1970-01-01
      相关资源
      最近更新 更多