Search code examples
pdfpdfboxdigital-signature

Digital Signature With TSA Timestamping adding certificates in chain in TSA response PDF Box giving error “not enough space to write signature”


I have created digital signature with timestamping the signature via TSA. In this I have added certificates to build chain in TSA response for building chain this works fine and signature also created, but while embedding this signature in pdf using PDF box API for Java it gives error not enough space to write signature. Is there any configuration available in PDF box to handle signature size?

Any help would be appreciated.


Solution

  • I assume you're using an embedded timestamp as in the CreateEmbeddedTimeStamp.java example, so you're using the space of the existing signature. That one is fixed, so you need to make it large enough:

    signatureOptions.setPreferredSignatureSize(...);
    

    with a number higher than the default (0x2500). The SignatureOptions object can be passed in the document.addSignature() call.