@@ -1099,6 +1099,49 @@ class PDFDocument {
10991099 } ) ;
11001100 }
11011101
1102+ #collectSignatureCertificates(
1103+ fields ,
1104+ collectedSignatureCertificates ,
1105+ visited = new RefSet ( )
1106+ ) {
1107+ if ( ! Array . isArray ( fields ) ) {
1108+ return ;
1109+ }
1110+ for ( let field of fields ) {
1111+ if ( field instanceof Ref ) {
1112+ if ( visited . has ( field ) ) {
1113+ continue ;
1114+ }
1115+ visited . put ( field ) ;
1116+ }
1117+ field = this . xref . fetchIfRef ( field ) ;
1118+ if ( ! ( field instanceof Dict ) ) {
1119+ continue ;
1120+ }
1121+ if ( field . has ( "Kids" ) ) {
1122+ this . #collectSignatureCertificates(
1123+ field . get ( "Kids" ) ,
1124+ collectedSignatureCertificates ,
1125+ visited
1126+ ) ;
1127+ continue ;
1128+ }
1129+ const isSignature = isName ( field . get ( "FT" ) , "Sig" ) ;
1130+ if ( ! isSignature ) {
1131+ continue ;
1132+ }
1133+ const value = field . get ( "V" ) ;
1134+ if ( ! ( value instanceof Dict ) ) {
1135+ continue ;
1136+ }
1137+ const subFilter = value . get ( "SubFilter" ) ;
1138+ if ( ! ( subFilter instanceof Name ) ) {
1139+ continue ;
1140+ }
1141+ collectedSignatureCertificates . add ( subFilter . name ) ;
1142+ }
1143+ }
1144+
11021145 get _xfaStreams ( ) {
11031146 const { acroForm } = this . catalog ;
11041147 if ( ! acroForm ) {
@@ -1414,6 +1457,18 @@ class PDFDocument {
14141457 // specification).
14151458 const sigFlags = acroForm . get ( "SigFlags" ) ;
14161459 const hasSignatures = ! ! ( sigFlags & 0x1 ) ;
1460+ if ( hasSignatures ) {
1461+ const collectedSignatureCertificates = new Set ( ) ;
1462+ this . #collectSignatureCertificates(
1463+ fields ,
1464+ collectedSignatureCertificates
1465+ ) ;
1466+ if ( collectedSignatureCertificates . size > 0 ) {
1467+ formInfo . collectedSignatureCertificates = Array . from (
1468+ collectedSignatureCertificates
1469+ ) ;
1470+ }
1471+ }
14171472 const hasOnlyDocumentSignatures =
14181473 hasSignatures && this . #hasOnlyDocumentSignatures( fields ) ;
14191474 formInfo . hasAcroForm = hasFields && ! hasOnlyDocumentSignatures ;
@@ -1441,6 +1496,11 @@ class PDFDocument {
14411496 IsSignaturesPresent : formInfo . hasSignatures ,
14421497 } ;
14431498
1499+ if ( typeof PDFJSDev !== "undefined" && PDFJSDev . test ( "MOZCENTRAL" ) ) {
1500+ docInfo . collectedSignatureCertificates =
1501+ formInfo . collectedSignatureCertificates ?? null ;
1502+ }
1503+
14441504 let infoDict ;
14451505 try {
14461506 infoDict = xref . trailer . get ( "Info" ) ;
0 commit comments