public function getTlsBindingsByAddress() : array
{
$bindMap = [];
$sniNameMap = [];
foreach ($this->vhosts as $vhost) {
if (!$vhost->isEncrypted()) {
continue;
}
foreach ($vhost->getBindableAddresses() as $bindAddress) {
$contextArr = $vhost->getTlsContextArr();
$bindMap[$bindAddress] = $contextArr;
if ($vhost->hasName()) {
$sniNameMap[$bindAddress][$vhost->getName()] = $contextArr["local_cert"];
}
}
}
// If we have multiple different TLS certs on the same bind address we need to assign
// the "SNI_server_name" key to enable the SNI extension.
foreach (array_keys($bindMap) as $bindAddress) {
if (isset($sniNameMap[$bindAddress]) && count($sniNameMap[$bindAddress]) > 1) {
$bindMap[$bindAddress]["SNI_server_name"] = $sniNameMap[$bindAddress];
}
}
return $bindMap;
}