@@ -927,16 +927,33 @@ protected function getSignatureParams(): array {
927927 }
928928
929929 private function buildBaseSignatureParams (array $ certificateData ): array {
930+ $ issuerCommonName = $ this ->normalizeCertificateFieldToString ($ certificateData ['issuer ' ]['CN ' ] ?? '' );
931+ $ signerCommonName = $ this ->normalizeCertificateFieldToString ($ certificateData ['subject ' ]['CN ' ] ?? '' );
932+
930933 return [
931934 'DocumentUUID ' => $ this ->libreSignFile ?->getUuid(),
932- 'IssuerCommonName ' => $ certificateData [ ' issuer ' ][ ' CN ' ] ?? '' ,
933- 'SignerCommonName ' => $ certificateData [ ' subject ' ][ ' CN ' ] ?? '' ,
935+ 'IssuerCommonName ' => $ issuerCommonName ,
936+ 'SignerCommonName ' => $ signerCommonName ,
934937 'LocalSignerTimezone ' => $ this ->dateTimeZone ->getTimeZone ()->getName (),
935938 'LocalSignerSignatureDateTime ' => (new DateTime ('now ' , new \DateTimeZone ('UTC ' )))
936939 ->format (DateTimeInterface::ATOM )
937940 ];
938941 }
939942
943+ private function normalizeCertificateFieldToString (mixed $ value ): string {
944+ if (is_array ($ value )) {
945+ $ flattened = [];
946+ array_walk_recursive ($ value , static function (mixed $ item ) use (&$ flattened ): void {
947+ if ($ item !== null ) {
948+ $ flattened [] = (string )$ item ;
949+ }
950+ });
951+ return implode (', ' , $ flattened );
952+ }
953+
954+ return $ value === null ? '' : (string )$ value ;
955+ }
956+
940957 private function addEmailToSignatureParams (array $ signatureParams , array $ certificateData ): array {
941958 $ email = $ this ->subjectAlternativeNameService ->extractEmailFromCertificate ($ certificateData );
942959 if ($ email ) {
0 commit comments