I'm evaluating Spire.PDF to sign digitaly PDFs using a Smart Card.
When the Card is inserted in the reader, the Card software copies the Certificate to the certificate store.
Then i load the certificate from the store and when i save the PDF it asks for the PIN as expected.
The problem is that it asks for the PIN 4 times before saving the document...
- Code: Select all
private void applySignature()
{
//Create a pdf document.
PdfDocument doc = new PdfDocument();
doc.LoadFromFile(@"C:\Temp\Autenticacao.Gov_Manual_de_Integracao_v1.4.1.pdf");
// Create one page
PdfPageBase page = doc.Pages[0]; //section.Pages.Add();
X509Store store = new X509Store("My");
store.Open(OpenFlags.ReadOnly);
PdfCertificate cert = new PdfCertificate(store.Certificates[0].GetRawCertData());
foreach (var item in store.Certificates)
{
if (item.SubjectName.Name.Contains("my name extracted from the card in other method") && item.IssuerName.Name.Contains("EC de Assinatura Digital Qualificada do Cartão de Cidadão"))
{
cert = new PdfCertificate(item.GetRawCertData());
break;
}
}
PdfSignature sig = new PdfSignature(doc, page, cert, "demo");
sig.Bounds = new RectangleF(new PointF(280, 600), new SizeF(260, 90));
sig.IsTag = true;
sig.Certificated = false;
sig.DocumentPermissions = PdfCertificationFlags.ForbidChanges;
sig.Date = DateTime.Now;
//Save doc file.
doc.SaveToFile(@"C:\Temp\Signature.pdf");
doc.Close();
//Launching the Pdf file.
System.Diagnostics.Process.Start(@"C:\Temp\Signature.pdf");
}
Is this normal?
I tried already the SecureBlackbox DLLs with this logic and it only ask the PIN once.
Thanks for your support