I am trying to verify a signature and am receiving an exception from the
bouncy castle API. I am not sure what I am doing wrong. The code is very
similar to the example in the iText Javadocs. I have attached the pdf that
I am trying to verify.
If anyone can determine why this error is occurring, I would be very
appreciative. Code is below.
Thanks,
Jason
public static DigitalId verifySignature(String inputFileName, String
fieldName){
PdfReader reader = null;
DigitalId id = null;
System.out.println(inputFileName);
System.out.println(fieldName);
try {
reader = new PdfReader(inputFileName);
AcroFields af = reader.getAcroFields();
/* DEBUG
System.out.println("Signature Names:");
ArrayList names = af.getSignatureNames();
for(int i = 0; i < names.size(); i++){
System.out.println(names.get(i));
}
*/
PdfPKCS7 pk = af.verifySignature(fieldName);
Calendar cal = pk.getSignDate();
boolean validSig = pk.verify();
X509Certificate cert = pk.getSigningCertificate();
String error = PdfPKCS7.verifyCertificate(cert,null,cal);
http://www.nabble.com/file/p18136048/signed.pdf signed.pdf
if(validSig && error == null){
Map fields = pk.getSubjectFields(cert).getFields();
id = new DigitalId(fields);
id.setValid(true);
id.setKeyAlgorithm(pk.getDigestAlgorithm() + "with" +
pk.getHashAlgorithm());
}
} catch(Throwable t){
t.printStackTrace();
} finally {
try { reader.close(); } catch(Throwable t){;}//eat exception
}
return id;
}
--
View this message in context:
http://www.nabble.com/BouncyCastle-Exception-when-trying-to-verify-signature-tp18136048p18136048.html
Sent from the iText - General mailing list archive at Nabble.com.
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Do you like iText?
Buy the iText book: http://www.1t3xt.com/docs/book.php
Or leave a tip: https://tipit.to/itexttipjar