I am trying to apply digital signature to existing PDF document using spire pdf and send the mail to the user but in the received pdf over the mail I am getting error as the certification is invalid. That means signature becoming invalid.
Can you please help with the issue.
Note: the code is working perfectly on local machine but when I am deploying the application on azure server I am getting this issue.
My Code:
PdfDocument doc = new PdfDocument("Test.pdf");
PdfPageBase page = doc.Pages[0];
PdfCertificate cert = new PdfCertificate("demo.pfx", "XXXX");
PdfSignature signature = new PdfSignature(doc, page, cert, "demo");
signature.ContactInfo = "Harry";
signature.Certificated = true;
signature.DocumentPermissions = PdfCertificationFlags.AllowFormFill;
var mem = new MemoryStream();
doc.SaveToStream(mem, Spire.Pdf.FileFormat.PDF);
mem.Position = 0;
doc.Close();
using (MailMessage email = new MailMessage())
{
MailAddress fromAddress = new MailAddress("XXXXX", "XXXX");
email.To.Add("XXXXX");
System.Net.Mime.ContentType ct = new System.Net.Mime.ContentType(System.Net.Mime.MediaTypeNames.Application.Pdf);
System.Net.Mail.Attachment attach = new System.Net.Mail.Attachment(mem, ct);
attach.ContentDisposition.FileName = "myFile.pdf";
email.From = fromAddress;
email.Attachments.Add(attach);
using (SmtpClient smtpClient = new SmtpClient())
{
smtpClient.Host = "XXXXX";
smtpClient.EnableSsl = true;
smtpClient.Port = XXXX;
smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
smtpClient.UseDefaultCredentials = true;
smtpClient.Credentials = new System.Net.NetworkCredential("XXXX", "XXXX");
smtpClient.Timeout = 6000000;
smtpClient.Send(email);
}
Note: Credientials are removed for security reason