Hey,
this was the key point for me:
PdfSignatureAppearance.VERISIGN_SIGNED

i had this previously:
PdfSignatureAppearance.SELF_SIGNED
and even tried
PdfSignatureAppearance.WINCER_SIGNED

but verisign was the only one that worked.
In any case, what i placed here was the whole working(for me) code for a
test with a source and destination file. What will probably be different for
you is the way you sign the digest and the way you get the certificate
array.

I think these are the key code changes:
...
                PdfSignatureAppearance appearance = 
stamp.getSignatureAppearance();
...
                // CcMethods.getChain() -> change to your method of getting
your certificate array
                appearance.setCrypto(null, CcMethods.getChain(), null,
PdfSignatureAppearance.VERISIGN_SIGNED);
...
                // new byte[128] is the "space"/"memory" reserved for the
signed digest array
                appearance.setExternalDigest(new byte[128], null, "RSA");
                appearance.preClose();
...
                // in my case a 128 byte array generated from my signing
method, hashDig is the document's digest (20 byte array)
                byte[] signedHash = CcMethods.sign(hashDig);

                PdfDictionary dic = new PdfDictionary();
                PdfPKCS7 sig = appearance.getSigStandard().getSigner();
                sig.setExternalDigest(signedHash, null, "RSA");
                dic.put(PdfName.CONTENTS, new
PdfString(sig.getEncodedPKCS1()).setHexWriting(true));
                appearance.close(dic);


Hope this helps.
Regards,
Pedro


-- 
View this message in context: 
http://itext-general.2136553.n4.nabble.com/Another-invalid-signature-thread-tp3003710p3013808.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

Reply via email to