Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

curl_getinfo($ch, CURLINFO_CERTINFO) is empty

Tags:

php

curl

ssl

I have PHP 7.2 from IUS repository, but the same behavior is on default PHP (CentOS 7.x).

Code:

$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);

Variable $certInfo is empty. I have tested curl with https://www.howsmyssl.com/a/check and it is supporting 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

What is wrong? curl? openssl? nss?

like image 656
paszczak000 Avatar asked Sep 03 '25 03:09

paszczak000


1 Answers

Try it with this: (updated domain)

$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);
like image 67
Miroslav Glamuzina Avatar answered Sep 05 '25 00:09

Miroslav Glamuzina