CryptographicException when saving digital signed pdf using Aspose code example

Hi, I’m trying to save a signed pdf file using exactly your code example, but this code is throwing the following exception when saving the file (doc.Save method):

CryptographicException: “The object identifier is poorly formatted”.
Do you have any idea of what is happening? Thank you!


This message was posted using Page2Forum from Create Digitally Signed PDF Documents - Aspose.Words for .NET

Hi
Jacobo,


Thanks for your inquiry. With a valid certificate, I was unable to reproduce this exception on my side. Could you please attach your input document and pfx certificate here for testing? I will investigate the issue on my side and provide you more information.

Best Regards,

Hi,


Thanks for your quick reply. I’m creating the pdf file with your example code:

// Create a simple document from scratch.

Document doc = new Document();

DocumentBuilder builder = new DocumentBuilder(doc);

builder.Writeln(“Test Signed PDF.”);

// Load the certificate from disk.

// The other constructor overloads can be used to load certificates from different locations.

X509Certificate2 cert = new X509Certificate2(

CertificateFolder + “TestCert.pfx”, “1111”);

// Pass the certificate and details to the save options class to sign with.

PdfSaveOptions options = new PdfSaveOptions();

options.DigitalSignatureDetails = new PdfDigitalSignatureDetails(

cert,

“Motivo”,

Lugar”,

DateTime.Now);

// Save the document as PDF with the digital signature set.

doc.Save(DocumentFolder + “Document.Signed Out.pdf”, options);


… changing the folder and the name/password of certificate only. The test’s certificate I’m using is attached to this reply. I’m using this certificate with old versions of Aspose.Pdf.Kit.Certificate and PdfFileSignature methods, and it’s working fine.

I hope this help you to investigate where is my problem (certificate, code…). Thank you!

Hi,


Thanks for your inquiry. While using the latest version of Aspose.Words i.e. 10.8.0, I was still unable to reproduce this issue on my side. Moreover, I would suggest you please visit the following link for downloading and using the latest version of Aspose.Words and let us know your findings:
http://www.aspose.com/community/files/51/.net-components/aspose.words-for-.net/default.aspx

Moreover, I have attached the digitally signed PDF file i.e. generated on my side here for your reference.

If we can help you with anything else, please feel free to ask.

Best Regards,

Hi there,


Thanks for your inquiry.

Could you also provide us some details about the machine your running on e.g Operating system.

Thanks,
Hi,

Thanks for both replies. I'm using the latest version of Aspose.Words.dll (10.8.0) and the result is being the same. When I'm catching this exception (or the program finishes "bad") the pdf file is being created and signed fine, but the exception is still there and I don't know why.

Machine details: VirtualPC VM with: MS Windows 2003 Server Enterprise Ed. SP2, IIS v6.0, .NET 3.5 SP1, SharePoint 2007.

I hope this information will help you to know why this exception is being launched.

Thank you very much for your time.

Hi Jacobo,


I have managed to reproduce the same problem at my side and linked this issue to the appropriate issue. You will be notified via this forum thread once this issue is resolved.


We apology for your inconvenience.

The issues you have found earlier (filed as WORDSNET-5729) have been fixed in this .NET update and this Java update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.