Skip to content

Commit 6d3046f

Browse files
authored
Merge pull request #7610 from LibreSign/backport/7608/stable33
[stable33] fix: hide account identifier from SignerCommonName
2 parents e6686c1 + 67c71c9 commit 6d3046f

2 files changed

Lines changed: 21 additions & 1 deletion

File tree

lib/Service/SignFileService.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -948,7 +948,11 @@ private function normalizeCertificateFieldToString(mixed $value): string {
948948
$flattened[] = (string)$item;
949949
}
950950
});
951-
return implode(', ', $flattened);
951+
$displayValues = array_values(array_filter(
952+
$flattened,
953+
static fn (string $item) => !preg_match('/^account:\s*/i', $item),
954+
));
955+
return implode(', ', $displayValues);
952956
}
953957

954958
return $value === null ? '' : (string)$value;

tests/php/Unit/Service/SignFileServiceTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1246,6 +1246,22 @@ public static function providerGetSignatureParamsCommonName(): array {
12461246
'',
12471247
'',
12481248
],
1249+
'legacy AD/LDAP cert with account: prefix in CN array' => [
1250+
[
1251+
'issuer' => ['CN' => 'LibreCode CA'],
1252+
'subject' => ['CN' => ['account:johndoe', 'John Doe']],
1253+
],
1254+
'LibreCode CA',
1255+
'John Doe',
1256+
],
1257+
'legacy AD/LDAP cert with spaced account: prefix in CN array' => [
1258+
[
1259+
'issuer' => ['CN' => 'LibreCode CA'],
1260+
'subject' => ['CN' => ['account: johndoe', 'John Doe']],
1261+
],
1262+
'LibreCode CA',
1263+
'John Doe',
1264+
],
12491265
];
12501266
}
12511267

0 commit comments

Comments
 (0)