websavers
Regular Pleskian
TITLE:
PHP libcurl fails to populate certinfo array
PRODUCT, VERSION, OPERATING SYSTEM, ARCHITECTURE:Plesk Onyx 17.8.11 Update #41 OS: CentOS Linux 7.6.1810 (Core). PHP: 7.2.15. curl curl 7.29.0 (x86_64-redhat-linux-gnu) libcurl/7.29.0
PROBLEM DESCRIPTION:Use $certinfo = curl_getinfo($ch, CURLINFO_CERTINFO); to get SSL certificate info and the certinfo variable is not populated -- it remains empty. If you also grab the basic info, it shows the array as being empty:
$info = curl_getinfo($ch);
print_r($info);
STEPS TO REPRODUCE:$info = curl_getinfo($ch);
print_r($info);
Set up a vhost on CentOS 7.5 running nginx direct to php-fpm with PHP v7.2.15 or 7.3.2. Add this to a PHP file in the web root, then visit the URL path:
ACTUAL RESULT:
PHP:
<?php
$domain = 'plesk.com';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://' . $domain);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
#curl_setopt($ch, CURLINFO_HEADER_OUT, true);
curl_setopt($ch, CURLOPT_STDERR, 'php://stdout');
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);
if(curl_exec($ch) === false){
echo '<p>Curl error: ' . curl_error($ch) . "</p>";
}
$info = curl_getinfo($ch);
print_r($info);
$certInfo = curl_getinfo($ch, CURLINFO_CERTINFO);
echo "<p>Certificate info for $domain: ";
print_r($certInfo[0]);
echo "</p><p>Test is done</p>";
?>
You'll notice that $certInfo prints as empty.
You can see it in action here: https://clients.websavers.ca/ssl_monitoring_test.php
EXPECTED RESULT:You can see it in action here: https://clients.websavers.ca/ssl_monitoring_test.php
The $certInfo var should be printing out an array of information about the SSL certificate like this (run on another domain on a non-Plesk server):
ANY ADDITIONAL INFORMATION:Certificate info for mydomain.com: Array ( [Subject] => CN = mydomain.com [Issuer] => C = US, O = Let's Encrypt, CN = Let's Encrypt Authority X3 [Version] => 2 [Serial Number] => 03c8d112700641145608b3daa7e29fb00f0a [Signature Algorithm] => sha256WithRSAEncryption [Public Key Algorithm] => rsaEncryption [X509v3 Key Usage] => DigitalSignature,KeyEncipherment [X509v3 Extended Key Usage] => TLSWebServerAuthentication,TLSWebClientAuthentication [X509v3 Basic Constraints] => CA:FALSE [X509v3 Subject Key Identifier] => 15:22:31:4AD:0F:EB:8F:63:3C:61:42:9E:CC:CE:E1:28:55:C1:F1 [X509v3 Authority Key Identifier] => keyid:A8:4A:6A:63:04:7DD:BA:E61:39:B7:A6:45:65:EF:F3:A8:EC:A1 [Authority Information Access] => OCSP-URI:http://ocsp.int-x3.letsencrypt.org, CAIssuers-URI:http://cert.int-x3.letsencrypt.org/ [X509v3 Subject Alternative Name] => DNS:mydomain.com,DNS:www.mydomain.com [X509v3 Certificate Policies] => Policy:2.23.140.1.2.1, Policy:1.3.6.1.4.1.44947.1.1.1, CPS:ISRG CPS v2.5 - Let's Encrypt - Free SSL/TLS Certificates [CT Precertificate SCTs] => SignedCertificateTimestamp:, Version:v1(0), LogID:E2:69:4B:AE:26:E8:E9:40:09:E8:86:1B:B6:3B:834:, 3E:E7:FE:74:88:FB:A4:8F:28:93:01:9DD:F1B:FE, Timestamp:Feb1721:13:14.6172019GMT, Extensions:none, Signature:ecdsa-with-SHA256, 30:45:02:21:00:E5:5E:85:0FF:21:368:2E:99:16:, 84:78:61:0C:7F:39:F2:98:71:38:5A:01:07F:3B:AD:, 49:70:A3:FC:E7:02:20:1C:9D:8A:18:4D:1D:9E:0A:A6:, 9C:79:BE:4A:0A:B2:6B:01:94:BE:7C:6B:08:A3:42:22:, ED:EC:9E:79:0F:FC:A9, SignedCertificateTimestamp:, Version:v1(0), LogID:63:F2B [Start date] => Feb 17 20:13:14 2019 GMT [Expire date] => May 18 20:13:14 2019 GMT [RSA Public Key] => 2048 [rsa(n)] => E2B2353E23839C18F2962A7CF7A417DBB80D1374A40D5E782A67388DFF69D0814A5BACF5910FA3879446FF4D8AD7F114B7ADE9A61EEC19D9D4B83431B2E62BB8EE10CFFCA6828533C5FE55230E53053079169A7E12D9D1EF4E65E56A8316A7AA221C5C8C91B8B88CB361937B7BAE38E03B83B42960EBCA12F697F7D8C3F63585A4C69751E24EFBB9B7A27B6A24F45C922C0AB2E514E35BC5F2A69D63084470543542D965F81F2A0E6D489D69BEE3655BD93A66AC4C3505727057BF89BCF2DBE264D905D6E0DF258516775DFBD07DD95A71DF39872AE594C1C25CA6BF9CAB621A90EDE6FE9F7ECDF389D9463E42F9734406CBF1BFAF83AB9FD628186206AC8C2D [rsa(e)] => 10001 [Signature] => 79:a4:c5:ac:b7:b6:56:5a:81:17:ea:f5:09:6b:b5:03:89:14:46:82:d8:8c:54:3e:8b:27:68:c3:cf:89:80:1e:45:85:7f:7c:28:db:15:b5:d6:da:1d:53:c7:a8:b1:c1:5f:63:f1:d2:49:f5:61:b4:a9:91:dc:64:4c:b2:1e:43:e2:8d:8a:4c:c5:57:6d:e8:92:fe:f0:57:23:c4:c1:b7:13:c1:ee:7f:5e:65:bd:f9:b8:45:f3:57:60:83:df:42:56:b1:31:93:45:16:c7:1d:3d:68:3c:8e:bb:e4:83:0b:b4:a2:03:94:d8:75:51:a2:35:14:14:78:da:ea:35:cd:07:84:4c:2f:80:cf:ec:87:66:27:02:2b:a3:a7:0d:7f:b7:81:1b:4e:06:1b:0e:28:6c:8b:2c:31:25:1c:be:54:ae:89:4e:1a:7d:9b:81:0c:7d:40:97:0f:ec:10:e8:2b:d3:e9:90:66:25:17:80:cf:f1:57:c5:2c:29:1b:c4:c2:21:af:89:0b:83:72:4d:40:2f:1f:b1:4e:8d:fc:d9:4a:fc:b8:3a:a9:33:2e:9d:70:b7:57:5c:95:2d:f9:2d:11:e9:7e:12:cb:14:fa:b9:ac:09:d3:ff:19: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d3cuc2NoZWxldy5jb20wTAYDVR0g BEUwQzAIBgZngQwBAgEwNwYLKwYBBAGC3xMBAQEwKDAmBggrBgEFBQcCARYaaHR0 cDovL2Nwcy5sZXRzZW5jcnlwdC5vcmcwggEDBgorBgEEAdZ5AgQCBIH0BIHxAO8A dgDiaUuuJujpQAnohhu2O4PUPuf+dIj7pI8okwGd3fHb/gAAAWj9TlB5AAAEAwBH MEUCIQDlXoUP3yE22C6ZFoR4YQx/OfKYcThaAQffO61JcKP85wIgHJ2KGE0dngqm nHm+SgqyawGUvnxrCKNCIu3snnkP/KkAdQBj8tvN6DvMLM8LcoQnV2szpI1hd4+9 daY4scdoVEvYjQAAAWj9TlB5AAAEAwBGMEQCIDH8qdsdJdJ0vrWyDpmRAkER6q4V PW77k/fNjZkdvvlLAiArlBcvw1ZG/ZTiQrvlCUqPF+6wrcI0m3qzcu98yu31zjAN BgkqhkiG9w0BAQsFAAOCAQEAeaTFrLe2VlqBF+r1CWu1A4kURoLYjFQ+iydow8+J gB5FhX98KNsVtdbaHVPHqLHBX2Px0kn1YbSpkdxkTLIeQ+KNikzFV23okv7wVyPE wbcTwe5/XmW9+bhF81dgg99CVrExk0UWxx09aDyOu+SDC7SiA5TYdVGiNRQUeNrq Nc0HhEwvgM/sh2YnAiujpw1/t4EbTgYbDihsiywxJRy+VK6JThp9m4EMfUCXD+wQ 6CvT6ZBmJReAz/FXxSwpG8TCIa+JC4NyTUAvH7FOjfzZSvy4OqkzLp1wt1dclS35 LRHpfhLLFPq5rAnT/xmmRUlR44fJs+WUfM8rkzF1Ag/elg== -----END CERTIFICATE----- )
This issue came about while using WHMCS -- the latest release of the software attempts to get SSL certificate info from domains and indicate if there's any problems and that they should set up an SSL cert.
The WHMCS techs said this about this issue: 'this is a bug with the PHP build or "curl" extension itself'
Note that certinfo *is* shown if you run curl via command line.
YOUR EXPECTATIONS FROM PLESK SERVICE TEAM:The WHMCS techs said this about this issue: 'this is a bug with the PHP build or "curl" extension itself'
Note that certinfo *is* shown if you run curl via command line.
Help with sorting out