From: <iva...@ip...> - 2017-08-08 14:25:00
|
Hello. I am trying to sign PDF remote using a C# client application to connect to SigServer's WebAPI. I managed to receive a valid PDF document from SignServer, but the signature field is corrupt: Error during signature verification. Signature contents incorrect, unrecognized, corrupted or suspicious data. Support information: SignDict /Contents illegal data. However, when I try to sign same PDF using PDF Signer demo the resulting PDF document and it’s signature look good. Could you pls provide any hints as to what I’m doing wrong? My C# client application code is provided below. We do use a custom signature image specified in SS config as base64 param. As mentioned, it works properly when signed via browser (the custom signature image is shown in PDF) but when invoked remotely via web api, the signature becomes corrupt. Thank you in advance, Ivan Pashchuk -------------------------------------------------------- using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Net <http://system.net/>; using System.Text; using System.Threading.Tasks; namespace HttpRequest { class Program { static void Main(string[] args) { byte[] pdfFile = File.ReadAllBytes("C:/Users/Ivan/Desktop/sample.pdf"); WebRequest request = WebRequest.Create("http://localhost:4447/signserver/process?workerId=2 <http://localhost:4447/signserver/process?workerId=2>"); request.Method = "POST"; request.ContentLength = pdfFile.Length; request.ContentType = "application/pdf"; Stream stream = request.GetRequestStream(); stream.Write(pdfFile, 0, pdfFile.Length); stream.Close(); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); StreamReader reader = new StreamReader(response.GetResponseStream()); Console.WriteLine("Response code: " + response.StatusCode); Console.WriteLine(response.Headers); StreamWriter GetResponsPdf = new StreamWriter("C:/Users/Ivan/Desktop/pdf/sample.pdf", false); GetResponsPdf.Write(reader.ReadToEnd()); GetResponsPdf.Flush(); GetResponsPdf.Close(); reader.Close(); Console.ReadKey(); } } } |