Hi Pedro, here my results on your signature :
- Drop the ASN1 byte wrapper ( these three bytes .. ) - Drop the DigestInfo structure holding the digest. In case of the rsa_sha1 signature the signature runs in a 'old school' / ancient mode where it's not expected to provide a DigestInfo structure but the very plain digest bytes. This may do the trick ... Greetings Andreas ----- original Nachricht -------- Betreff: Re: [iText-questions] Another invalid signature thread Gesendet: Mo, 25. Okt 2010 Von: P3d3r0s0<zas...@gmail.com> > > Hello again, > > I did the detached method now, learned a few things on what works a little > better but still gives an error (Error encountered while BER decoding:)... > sample: > http://www.filefactory.com/file/b3hcd3b/n/signed_pdf > > Key code samples that i believe might be the reason for the errors: > PdfSignatureAppearance appearance = stamp.getSignatureAppearance(); > ... > appearance.setCrypto(null, CcMethods.getChain(), null, > PdfSignatureAppearance.SELF_SIGNED); > ... > PdfSignature dic1 = new PdfSignature(PdfName.ADOBE_PPKLITE, > PdfName.ADBE_PKCS7_DETACHED); > ... > // i believe this reserves 128 bytes for the signedHash byte array > int csize = 128; > HashMap<PdfName, Integer> exc = new HashMap<PdfName, Integer>(); > exc.put(PdfName.CONTENTS, new Integer(csize * 2 + 2)); > appearance.preClose(exc); > ... > // regurns the signedHash (verified) > byte[] signedHash = CcMethods.sign(hashDig); > PdfDictionary dic = new PdfDictionary(); > dic.put(PdfName.CONTENTS, new PdfString(signedHash).setHexWriting(true)); > appearance.close(dic); > > > i didnt things here like setting the name and date on the signature thats > why i have all the "...". > i believe im following the howtosign to the letter, but i still have errors. > > -- > View this message in context: > http://itext-general.2136553.n4.nabble.com/Another-invalid-signature-thread- > tp3003710p3010293.html > Sent from the iText - General mailing list archive at Nabble.com. > > ---------------------------------------------------------------------------- > -- > Nokia and AT&T present the 2010 Calling All Innovators-North America > contest > Create new apps & games for the Nokia N8 for consumers in U.S. and Canada > $10 million total in prizes - $4M cash, 500 devices, nearly $6M in > marketing > Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store > http://p.sf.net/sfu/nokia-dev2dev > _______________________________________________ > iText-questions mailing list > iText-questions@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/itext-questions > > Many questions posted to this list can (and will) be answered with a > reference to the iText book: http://www.itextpdf.com/book/ > Please check the keywords list before you ask for examples: > http://itextpdf.com/themes/keywords.php > --- original Nachricht Ende ---- ------------------------------------------------------------------------------ Nokia and AT&T present the 2010 Calling All Innovators-North America contest Create new apps & games for the Nokia N8 for consumers in U.S. and Canada $10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store http://p.sf.net/sfu/nokia-dev2dev _______________________________________________ iText-questions mailing list iText-questions@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions Many questions posted to this list can (and will) be answered with a reference to the iText book: http://www.itextpdf.com/book/ Please check the keywords list before you ask for examples: http://itextpdf.com/themes/keywords.php