Skip to content

Commit

Permalink
CertificateUtils: Split also unknow cert alt names correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
yhabteab committed Sep 4, 2023
1 parent c2cce53 commit a1148f3
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions library/X509/CertificateUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,16 @@ public static function splitSANs(?string $sanStr): array
{
$sans = [];
foreach (Str::trimSplit($sanStr) as $altName) {
[$k, $v] = Str::trimSplit($altName, ':');
if (strpos($altName, ':') === false) {
[$k, $v] = Str::trimSplit($altName, '=', 2);
} else {
[$k, $v] = Str::trimSplit($altName, ':', 2);
}

$sans[$k][] = $v;
}

$order = array_flip(['DNS', 'URI', 'IP Address', 'email']);
$order = array_flip(['DNS', 'URI', 'IP Address', 'email', 'DirName']);
uksort($sans, function ($a, $b) use ($order) {
return ($order[$a] ?? PHP_INT_MAX) <=> ($order[$b] ?? PHP_INT_MAX);
});
Expand Down

0 comments on commit a1148f3

Please sign in to comment.