Hi Gonçalo,
I once stumbled across this, too.
Within the signatures loop I grap the raw signature bytes and processed them
using my favorite crypto toolkit ( in my case iaik ) :
// get the bytes
PdfDictionary dict = af.getSignatureDictionary( name );
PdfString contents =
(PdfString)PdfReader.getPdfObject(dict.get(PdfName.CONTENTS));
// process into a signature object
InputStream sigIS = new ByteArrayInputStream(contents.getOriginalBytes()
ASN1Object asnObject = DerCoder.decode( sigIS );
SignedData signedData = new SignedData(asnObject);
...
I'm not quite sure whether problem with the uninitialized signature is caused
by the iText implementation or by Bouncy Castle ...
Good luck
Andreas
----- original Nachricht --------
Betreff: [iText-questions] Extract PKCS#7s from a PDF
Gesendet: Fr, 23. Jan 2009
Von: Gonçalo Almeida
Hello all
I have a question regarding the extraction of PKCS#7 signatures from a signed
PDF.
I want to extract to a file, an array of bytes or whatever. How can I do this
having the following code:
PdfReader reader = null;
reader = new PdfReader(signedFile); AcroFields af =
reader.getAcroFields(); ArrayList names = af.getSignatureNames();
// iterates over the several signatures for (int k = 0; k <
names.size(); ++k) { String name = (String) names.get(k);
PdfPKCS7 pk = af.verifySignature(name);
pk.getEncodedPKCS7(); //this would be the method invoked in order to obtain the
PKCS7 byte array } However I get a "java.security.SignatureException:
object not initialized for signing" because the method above tries to sign the
document, if the variable externalDigest is null.Now, the problem is, during
the pdf reading, this variable is not set, only the digest variable is.Because
I have no way of accessing the digest variable I cannot set the externalDigest
variable to its value.Can anybody help me with this?
--
Best regards
Gonçalo Almeida
--- original Nachricht Ende ----
------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://www.1t3xt.com/docs/book.php