Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Mon Feb 24, 2020 11:43 am

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

[email protected]
 
Posts: 1
Joined: Thu Feb 14, 2019 10:49 am

Tue Feb 25, 2020 2:08 am

Hello,

Thanks for your inquiry.
I have reproduced your issue and logged it in our bug tracking system with the ticket SPIREPDF-3067. If there is any update, we will let you know.
Apologize for the inconvenience caused.

Sincerely,
Rachel
E-iceblue support team
User avatar

rachel.lei
 
Posts: 1571
Joined: Tue Jul 09, 2019 2:22 am

Fri Jun 05, 2020 2:24 am

Hello,

Hope you are doing well.
After the further investigation by our Dev team, we found that to use the PFX certificate on the Azure server, you need to set the App Setting WEBSITE_LOAD_USER_PROFILE to 1, as shown below. Please verify it on your side and then tell us the result. Looking forward to your further feedback.

Azure_Application_Setting.png

Article for your kind reference: https://azure.microsoft.com/zh-tw/blog/ ... -websites/

Sincerely,
Rachel
E-iceblue support team
User avatar

rachel.lei
 
Posts: 1571
Joined: Tue Jul 09, 2019 2:22 am

Tue Jun 09, 2020 10:02 am

Hello,

Greetings from E-iceblue!
Have you verified it on your side? What's your test result?
Any feedback would be greatly appreciated!

Sincerely,
Rachel
E-iceblue support team
User avatar

rachel.lei
 
Posts: 1571
Joined: Tue Jul 09, 2019 2:22 am

Return to Spire.PDF