Free Support Forum - aspose.com

Document signing with certificate and timestamp


#1

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


#2

@micivil

Thank you for contacting support.

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


#3

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)


#4

@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.


#5

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


#6

@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.


#7

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


#8

@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.


#9

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


#10

@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.