I am using FreeSpire.PDF version 10.2.0.
I have successfully added certificate chain to signature. I am about to get LTV enabled using the code below. I get the signed PDF but it is not LTV Enabled. Where am I wrong?
- Code: Select all
private string SignDocument(string _base64String)
{
try
{
string ReturnValue = "";
PdfDocument doc = new PdfDocument(Convert.FromBase64String(_base64String));
PdfPageBase page = doc.Pages[doc.Pages.Count - 1];
var _filepath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "LogsFiles\\");
X509Certificate2Collection collection = new X509Certificate2Collection();
collection.Import(_filepath + "xxxxxx.pfx", "yyyyy", X509KeyStorageFlags.DefaultKeySet);
PdfPKCS7Formatter formatter = new PdfPKCS7Formatter(collection[0], false);
formatter.ExtraCertificateStore = collection;//full certificate chain support.
formatter.TimestampService = new TSAHttpService("http://xxxxx.com", "yyy", "xxxxxxxx");
formatter.OCSPService = new OCSPHttpService("http://yyyyy.com");
PdfOrdinarySignatureMaker maker = new PdfOrdinarySignatureMaker(doc, formatter);
Spire.Pdf.Interactive.DigitalSignatures.PdfSignature signature = maker.Signature;
//Setting Signature Information
signature.Name = "Test";
PdfSignatureAppearance appearance = new PdfSignatureAppearance(signature);
appearance.DateLabel = "Date: ";
appearance.NameLabel = "Name";
//1.Signature and signature details
appearance.GraphicMode = Spire.Pdf.Interactive.DigitalSignatures.GraphicMode.SignDetail;
//The location of the signature in the pdf
maker.MakeSignature("signature", doc.Pages[doc.Pages.Count - 1], (page.ActualSize.Width / 2) - 50, page.ActualSize.Height - 100, 110, 50, appearance);
var memStr = new MemoryStream();
doc.SaveToStream(memStr);
byte[] bytes = memStr.ToArray();
ReturnValue = Convert.ToBase64String(bytes);
doc.Close();
return ReturnValue;
}
catch (Exception ex)
{
return ex.Message;
}
}
Please note that both root certificate of the document signing and root certificate od the timestamp chain is trusted.
Show Signer’s Certificate - I have the hole chain ( root certificate which is trusted, intermediate/issuer and leaf certificate)
Advanced Properties - also I have the hole chain on the same logic like signer certificate. This certificate is used by the timestamp authority to sign the timestamp.
What i get now using OCSP validation it that LTV is not enabled, please see the picture, Why?
Additional information: please note that everything is fine (LTV is enabled) when I am signing the document manually with the same certificate in acrobat reader, and using the same timestamp in the security panel
Thanks,