Document signing with certificate and timestamp using Aspose.PDF (C#)

Hi.

I’m trying to sign a document (totally empty - Empty.pdf (3.7 KB)
) using a timestamp. This is the code used. It’s almost identical to the example from your docs:

 using (Document document = new Document(<empty.pdf>)) {
        using (PdfFileSignature signature = new PdfFileSignature(document)) {
          PKCS7 pkcs = new PKCS7(<cert path>, <password>);
          TimestampSettings timestampSettings = new TimestampSettings("http://timestamp.digicert.com", null); 
          pkcs.TimestampSettings = timestampSettings;
          System.Drawing.Rectangle rect = new System.Drawing.Rectangle(0, 0, 100, 100);
          signature.Sign(document.Pages.Count, "Signature Reason", "Contact", "Location", true, rect, pkcs);
          signature.Save(<signed.pdf>);
        }
      }

and I’m little bit confused by the result:

image.png (8.4 KB)

Signed.pdf (91.3 KB)

Obviously the document has been signed by the TSA certificate, but not my one.

Used key:
cert.zip (2.6 KB)
Password: test
(it’s just a dev self-signed certificate, so no worries :))

Is it an issue or is there something obvious I’m missing?

Thank you for your help.

Regards,
Michal

@micivil

Thank you for contacting support.

We are looking into your requirements and will share our feedback with you soon.

Hi.

Thanks a lot.
If it helps, when the timestamp part is removed:

using (Document document = new Document(<empty.pdf>)) {
        using (PdfFileSignature signature = new PdfFileSignature(document)) {
          PKCS7 pkcs = new PKCS7(<cert path>, <password>);
          // TimestampSettings timestampSettings = new TimestampSettings("http://timestamp.digicert.com", null); 
          // pkcs.TimestampSettings = timestampSettings;
          System.Drawing.Rectangle rect = new System.Drawing.Rectangle(0, 0, 100, 100);
          signature.Sign(document.Pages.Count, "Signature Reason", "Contact", "Location", true, rect, pkcs);
          signature.Save(<signed.pdf>);
        }
      }

the result looks as expected:
image.png (4.7 KB)
Signed.pdf (85.9 KB)

@micivil

Thank you for your kind feedback.

Please note that the timestamp feature is supported by Aspose.PDF for .NET API as offered by Adobe Acrobat. So you can sign the PDF document without specifying TimestampSettings as per your requirements. However, we are glad to know that you are getting expected results. Please keep using our API and in event of any further query, feel free to ask.

Hi.
I’m terribly for the misunderstanding.
The issue, as described in the first post, still remains. What I wanted to say in the second, was when the timestamp is removed, the PDF is signed by the certificate provided. However I’d expect the same to happen in the first scenario as well, which just one exception - the timestamp being added.
So something like that:
doc3 signed.pdf (507.8 KB)
image.png (17.6 KB)

Which means, the file is signed by my certificate and the timestamp at the same time. Which unfortunately does not happen in the first scenario described in the first post.

Is the issue more clear now?

Thanks a lot for your help. This only issue is preventing us to use the Aspose.PDF in the upcoming project at the moment. So if we’re able to solve it, we’re almost done :slight_smile:

Regards,
Michal

@micivil

Thank you for elaborating it further.

We have logged a ticket with ID PDFNET-45987 in our issue management system for detailed investigations. The ticket ID has been linked with this thread so that you will receive notification as soon as some significant updates will be available in this regard.

HI.

Thanks a lot. We can use a workaround - to sign the documents with the timestamp and our certificate in two steps - using two signature fields. So most probably we’ll stick to Aspose in the project.
Thanks a lot for your help a I’m looking forward to have this one fixed :slight_smile:

Best regards,
Michal Vilim

@micivil

We are pleased to know that mentioned workaround can be used until the ticket is resolved. We will let you know as soon as some significant updates will be available.

Hi.
Unfortunately, we’ve ran more tests today and when the document is signed using a timestamp is missing the timestamp information:

image.png (193.8 KB)
doc3_Signed.pdf (341.9 KB)

So at the moment we cannot use Aspose to cover all the scenarios. Do you happen to have some timelines , when the issue could be fixed? It will help is in the further planning of the project.

I’m sorry I should have spatted this flaw before.

Regards,
Michal Vilim

@micivil

Thank you for elaborating it further.

We are afraid logged ticket may take some months to resolve owing to previously logged and critical tickets. However, we have logged your concerns and will let you know once some significant updates will be available.

Hello. I’m looking for a PDF SDK that offers this functionality, certification signing with an embedded timestamp. The latest version still does not seem to support this, is PDFNET-45987 going to be resolved any time soon? Unless there is a workaround to the problem I can’t use this SDK.

Thanks

@steve.bickmore.pb,

I regret to inform that issue is still unresolved. I request for your patience an we will share good news with you soon.

Hello. I have the same problem when using Timestamp. I am interested in being able to sign PDF documents with timestamp. When will this issue be fixed?

@screspo

Regretfully, the earlier logged ticket has not been yet resolved. However, we have recorded your concerns and will surely inform you once we have some news about its fix. Please spare us some time.

We are sorry for the inconvenience.

Do you have an ETA for a possible fix for this item? This is affecting a very important process for us.

@screspo

We are afraid that an ETA for the ticket resolution cannot be provided at this moment as its investigation is not yet completed. The ticket is complex in nature and there are other parallel tasks need to be completed as well. We have however recorded your concerns already and will surely consider them during investigation. We will provide an update in this forum thread as soon as we have it regarding issue fix. We apologize for your inconvenience.