Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. TlsHelper.php

function TlsHelper::checkCertificateHost

Match hostname against a certificate.

Parameters

mixed $certificate X.509 certificate:

string $hostname Hostname in the URL:

string $cn Set to the common name of the certificate iff match found:

File

vendor/composer/composer/src/Composer/Util/TlsHelper.php, line 31

Class

TlsHelper
@author Chris Smith <chris@cs278.org>

Namespace

Composer\Util

Code

public static function checkCertificateHost($certificate, string $hostname, ?string &$cn = null) : bool {
    $names = self::getCertificateNames($certificate);
    if (empty($names)) {
        return false;
    }
    $combinedNames = array_merge($names['san'], [
        $names['cn'],
    ]);
    $hostname = strtolower($hostname);
    foreach ($combinedNames as $certName) {
        $matcher = self::certNameMatcher($certName);
        if ($matcher && $matcher($hostname)) {
            $cn = $names['cn'];
            return true;
        }
    }
    return false;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal