Skip to content

Commit 87a5400

Browse files
authored
Merge pull request #7609 from LibreSign/backport/7608/stable32
[stable32] fix: hide account identifier from SignerCommonName
2 parents c1c33df + 3ea9cc1 commit 87a5400

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
@@ -1244,6 +1244,22 @@ public static function providerGetSignatureParamsCommonName(): array {
12441244
'',
12451245
'',
12461246
],
1247+
'legacy AD/LDAP cert with account: prefix in CN array' => [
1248+
[
1249+
'issuer' => ['CN' => 'LibreCode CA'],
1250+
'subject' => ['CN' => ['account:johndoe', 'John Doe']],
1251+
],
1252+
'LibreCode CA',
1253+
'John Doe',
1254+
],
1255+
'legacy AD/LDAP cert with spaced account: prefix in CN array' => [
1256+
[
1257+
'issuer' => ['CN' => 'LibreCode CA'],
1258+
'subject' => ['CN' => ['account: johndoe', 'John Doe']],
1259+
],
1260+
'LibreCode CA',
1261+
'John Doe',
1262+
],
12471263
];
12481264
}
12491265

0 commit comments

Comments
 (0)