Free Support Forum - aspose.com

Signing encrypted PDF with PKCS1 certificate type fails (Aspose.PDF for .NET)

Hi,
I am trying to sign encrypted PDF file using PKCS1 certificate type and it fails with an error message:
PKCS#1 does not support ocsp, timestamp settings, use PKCS#7.

I am using PDF Net for C#.
It works when the file is not encrypted.
It works when the PKCS#7 certificate type is selected.
it works in the older versions (e.g version 10).
it doesn’t work in the latest 20.4 version.

Please let me know how can I achieve it?

Thanks.

@Hrayr.Gevorgyan,

Thanks for contacting support.

Can you please share source files along with sample code so that we may further investigate to help you out.

@Adnan.Ahmad,
Thanks for quick response,

Here is a code that I use for signing PDF:

using (Document srcDocument = new Document(sourcePath))
{
//Encrypt PDF file
using (var fileSecurity = new PdfFileSecurity(srcDocument))
{
fileSecurity.EncryptFile(string.Empty, string.Empty, DocumentPrivilege.ForbidAll, KeySize.x128, Algorithm.RC4);
fileSecurity.Save(encryptPath);
}

using (var encrDocument = new Document(encryptPath))
using (var signature = new PdfFileSignature(encrDocument))
{
	var pkcs1 = new PKCS1(certPath, "password");
	System.Drawing.Rectangle rect = new System.Drawing.Rectangle(100, 100, 200, 100);

	signature.Sign(1, "SignReason", "SignContact", "SignLocation", true, rect, pkcs1);

	//save output PDF file
	signature.Save(signedPDF);
}

}

And here is the PDF file I’ve used:
Sample.pdf (39.9 KB)
And the certificate:
personal.zip (2.6 KB)

@Hrayr.Gevorgyan,

We have tested the scenario in our environment and were able to notice the issue. We have logged it as PDFNET-48049 in our issue tracking system. We will further look into details of the issue and keep you posted with the status of its correction. Please be patient and spare us little time.

We are sorry for the inconvenience.

@Adnan.Ahmad,
Thank you for your reply, looking forward to the good news about the fix.

Thanks.

@Hrayr.Gevorgyan,

We will share good news with you soon.

1 Like