Signing with certificate and TSA using Aspose.PDF

Hello.

I’m trying to sign a document.
TEST.pdf (28.1 KB)
using the following Test-Certificate:
D-TRUST GmbH - Test_CSM017878135.zip (8.9 KB)
Password: H0FS7R1A6R

I’m using the following code:

Dim pdfDocument As Document = New Document(txtFilename.Text)

Using pdfDocument

    Dim signature As PdfFileSignature = New PdfFileSignature(pdfDocument)        
    Dim pkcs As PKCS7 = New PKCS7("C:\Users\rwa\Desktop\Aspose Durchstich\D-TRUST GmbH - Test_CSM017878135.p12", "H0FS7R1A6R")
            
    Dim rect As System.Drawing.Rectangle = New System.Drawing.Rectangle(40, 0, 500, 100)
    signature.Sign(pdfDocument.Pages.Count, "Reason-Text", "test@123.com", "Location-Text", True, rect, pkcs)

    signature.Save(Path.Combine(DataDir, "Testdokument_Zeitstempel.pdf"))
    signature.Close()


End Using

This seems to be OK. The PDF is signed by the Test-Certificate an it looks like This:
2023-08-03 08_41_48-Testdokument_Zeitstempel.pdf - Adobe Acrobat Reader (64-bit).png (10.5 KB)

However if i add a timeserver to the code like this:

Dim pdfDocument As Document = New Document(txtFilename.Text)

Using pdfDocument

    Dim signature As PdfFileSignature = New PdfFileSignature(pdfDocument)        
    Dim pkcs As PKCS7 = New PKCS7("C:\Users\rwa\Desktop\Aspose Durchstich\D-TRUST GmbH - Test_CSM017878135.p12", "H0FS7R1A6R")
    
    Dim TimestampSettings As TimestampSettings = New TimestampSettings("https://freetsa.org/tsr", String.Empty)
    pkcs.TimestampSettings = TimestampSettings

    Dim rect As System.Drawing.Rectangle = New System.Drawing.Rectangle(40, 0, 500, 100)
    signature.Sign(pdfDocument.Pages.Count, "Reason-Text", "test@123.com", "Location-Text", True, rect, pkcs)

    signature.Save(Path.Combine(DataDir, "Testdokument_Zeitstempel.pdf"))
    signature.Close()


End Using

The document has been signed by the TSA certificate, but not my one and it looks like this:

2023-08-03 08_46_47-Testdokument_Zeitstempel.pdf - Adobe Acrobat Reader (64-bit).png (15.8 KB)

How can i fix/workaround this issue?

ps: I tested the same functionality in aspose.words - there it seems to work!

regards

@g.erdl.ots-ag.de

Can you please also share the output PDF document that has been generated in your environment? We will test the scenario in our environment and address it accordingly.

Sure.
Here are the documents:
Test_out.pdf (586.6 KB)
Test_out_with_timestamp.pdf (581.8 KB)

regards

@g.erdl.ots-ag.de

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): PDFNET-55205

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.