Problem recurrence:
<?php
function getCertInfo($domain)
{
$context = stream_context_create([
'ssl' => [
'capture_peer_cert' => true,
'capture_peer_cert_chain' => true,
],
]);
$client = stream_socket_client("ssl://{$domain}:443", $errorCode, $errorMessage, 30, STREAM_CLIENT_CONNECT, $context);
if ($client === false) {
var_dump("!!!open {$domain} socket connection fail. {$errorMessage}($errorCode) !!!";
return false;
}
$params = stream_context_get_params($client);
if (empty($params['options']['ssl']['peer_certificate'])) {
var_dump("!!!{$domain} stream_context_get_params options ssl peer_certificate is empty!!!");
return false;
}
return openssl_x509_parse($params['options']['ssl']['peer_certificate']);
}
Solution: $context add verify_ Peer configuration
<?php
$context = stream_context_create([
'ssl' => [
'capture_peer_cert' => true,
'capture_peer_cert_chain' => true,
'verify_peer' => false,
],
]);