We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Creating Digital Signature

I install a PFX file into my Certificate Store then I check the option that enable strong private key protection.
After this, I'm prompted with the CryptoAPI Private Key Windows Form wich I set my security level to High.

Executing the following code, the CryptoAPI ask me to insert the password.

Dim pdfDoc As Syncfusion.Pdf.PDFDocument
Dim provider As IPDFCertificateStore
Dim cert As IPDFCertificate
Dim signInfo As IPDFDigitalSignature
Dim rect As RectangleF

pdfDoc = PDFDocument.Load(strFilePath)
provider = pdfDoc.Security.GetCertificateStore(StoreType.MY)
cert = provider.FindBySubject(strFullname)

rect = New RectangleF(0, 0, 594, 200)
signInfo = pdfDoc.Security.CreateDigitalSignature(pdfDoc.LastPage, rect, cert)

pdfDoc.Save("d:\teste_" & GetGUID() & ".pdf")
pdfDoc.Close()


First question: If I press the cancel button the pdfDoc.Save(...) function generates a PDF with an invalid certificate.
How can I get this information programmaticaly?

Second question: If I insert the right password, and immediatly certificate different PDFs everything works fine, but is there any possiblity to prompt the password every time?


Note: I'm running the above code under a thread.


Thank's in advance!

1 Reply

DK Dhivya K Syncfusion Team December 28, 2006 07:20 AM UTC

Hi Ricardo,

Thanks for your detailed explanation and code snippets.

I tested the issue as follows
->installed the certificate as you said[set private key with high level security option]
-> when I signed the document,I clicked the "cancel" button.
I received the output PDF signed with the certificate that I have mentioned in my code with verifcation error which is expected as we didn't provide the password[pressed cancel button].

1) Regarding your first question, Pdf has been signed by the certificate that you have mentioned but with verification error. You can find the details of the certificate that has been signed by viewing the signature properties. However, I am not clear about the question you have asked. Can you please ellobrate about which information you want to get programmatically?
Here is a sample PDF document generated.
Sample.pdf


2) Regarding your second question,

Can you please clarify me whether you are trying to sign multiple PDF documents with a single certificate using threads?
If so is the case,it prompts for the password for each thread.
Here is a sample for your reference:
Multithreading.zip

Please let me know if my assumptions doen't meets your need. Also, Can you please provide me the Essential studio version your are using. This will help me investigating further on this issue.

Regards,
Dhivya.

Loader.
Live Chat Icon For mobile
Up arrow icon