I signed the pdf successfully and also verified the pdf successfully but the "SignName" property of class PdfPKCS7 always returns null.
I don't know why? Am I missing something during the pdf signing process or verification process?
//res.SignName always returns null.
validite = "Validated : " + res.SignName;
Pdf signing code see here: "Invalid algorithm specified" when pdf signing with Itext 5.5.13.2
and Verification Code is given below.
private void Button1_Click(object sender, EventArgs e)
{
PdfReader reader;
reader = new PdfReader(pdfFilePath.Text);
try
{
AcroFields acf = reader.AcroFields();
List<string> sgnoms = acf.GetSignatureNames();
List<string> sgnoms2 = acf.GetBlankSignatureNames();
Org.BouncyCastle.X509.X509Certificate cert;
if (sgnoms.Count > 0)
{
foreach (object obj in sgnoms)
{
PdfPKCS7 res = acf.VerifySignature(obj.ToString());
string validite = "Not Validate";
DateTime cal = res.SignDate;
if (res.SigningCertificate.IsValid(DateTime.Now) && res.Verify())
//res.SignName` Always returns null
validite = "Validated : " + res.SignName;
res = null;
validite = null;
cal = default(DateTime);
}
}
else
throw new Exception("Document not sign!");
reader = null;
acf = null;
sgnoms = null;
sgnoms2 = null;
}
catch (Exception ex)
{
}
}
Is any alternative to get the Signer Name? Or anything missing in the code?
Please check it, Unbale to get the reason. Am I missing something during the pdf signing process? or Am I missing something during the pdf verification process?
Any ideas, working code and suggestions are welcome.
Thanks in advance.
The
SignNameproperty is the value of the Name entry of the signature dictionary. This entry is specified as:EXAMPLE 1 From the certificate of the signer.
(ISO 32000-1, Table 252 – Entries in a signature dictionary)
This entry is optional, so the value you retrieve may well be null.
There is also a hint where you can look for the signer name here: in the signer certificate! Thus, consider inspecting the
SigningCertificateproperty of yourPdfPKCS7object.