I can successfully sign a PDF with Syncfusion Pdf library 19.2.0.44, it shows up in Adobe Reader as "Signed and all signatures are valid". However, it does not say that it's LTV enabled. I have embedded timestamp information and I'm attaching OCSP data to AddExternalSigner. What could be missing, I set EnableLtv to true?
|
X509Certificate2 digitalID = new X509Certificate2(@"Your pfx certificate", "password");
List<X509Certificate2> certificates = new List<X509Certificate2>();
certificates.Add(digitalID);
signature.AddExternalSigner(externalSignature, certificates, null);
signature.EnableLtv = true;
signature.TimeStampServer = new TimeStampServer(new Uri("Timestamp link")); |
Hello,
so the certificate we have received from Ensured/Sectigo has 2 intermediate certificates and the CA/root. It seems that the root doesn't have OCSP, but the two intermediate certs and the leaf cert do (but there are two different URLs for the intermediate certs). In your example you're not passing the OCSP response in AddExternalSigner, I assume I need to do that with an line HSM-based signer? From running Fiddler it doesn't seem like SyncFusion will access the OCSP during signing (and Adobe shows it as not LTV-enabled. Could the issue be that there needs to be two or three OCSP responses, one for each cert?
/Hakan
|
|
Hmm, that made no difference, it still says it's not LTV enabled. Does your output.pdf actually show LTV enabled?
|
var certificates = new List<X509Certificate2>
{
new X509Certificate2(signingCert.Cer)
};
var ocspClient = new OCSPClient();
var certParser = new X509CertificateParser();
var cert = certParser.ReadCertificate(signingCert.Cer);
var chain = new X509Chain();
chain.Build(certificates[0]);
var chainElements = new List<X509Certificate2>();
foreach (var item in chain.ChainElements)
{
chainElements.Add(item.Certificate);
if(!certificates.Contains(item.Certificate))
certificates.Add(item.Certificate);
}
var issuer = certParser.ReadCertificate(chainElements[1].RawData);
var result = ocspClient.ValidateOCSP(cert, new List<Org.BouncyCastle.X509.X509Certificate>() { issuer });
// This will cause an "invalid signature":
//signature.AddExternalSigner(externalSigner, certificates, null/*result.Data*/);
// This will cause a valid signature, but not LTV-enabled:
signature.AddExternalSigner(externalSigner, certificates , result.Data);
signature.EnableLtv = true;
|
Ah, so even if the certificate that's loaded from Azure has all the certificates including the root, they have to be split up into the certificates list? The documentation is very sparse on this, would you mind updating that to help others?
Thank you for solving it though! Can you please remove the attached samples as it has our Azure details in there?
Thanks,
/Hakan