We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Invalid MAC Exception

I’ve just started getting an exception when saving a signature.

This is the exception:
class com.aspose.pdf.internal.ms.System.Security.Cryptography.z22: Invalid MAC - file may have been tampered! —> class com.aspose.pdf.internal.p885.z10: Invalid MAC - file may have been tampered!

Here’s a snippet of the code I’m using
// Create PdfFileSignature instance
PdfFileSignature pdfSignSingle = new PdfFileSignature();

    // Bind the source PDF by reading contents of Stream
    pdfSignSingle.bindPdf(new ByteArrayInputStream(((ByteArrayOutputStream) out).toByteArray()));

    // Sign the PDF file using PKCS1 object
    pdfSignSingle.sign(1,signReason, signContact, signLocation, true, new Rectangle(36, 748, 144, 780), cert);

    // Save final output
    pdfSignSingle.save(destination); 

Any insights greatly appreciated!

@mlindsay-hellosign

Thanks for contacting support.

Would you please share your sample PDF document along with the Certificate file (.pfx), so that we can test the scenario in our environment and address it accordingly.

Derp. I’d regenerated the certificate and entered the new keystore password incorrectly. It’s working now. Thanks for responding so promptly.

@mlindsay-hellosign

Thanks for acknowledging us.

It is good to know that your issue has been resolved. Please keep using our API and in event of any further query, please feel free to ask.