Categories
Mastering Development

Digital signatures invalid when I use the iTextSharp

This is my Form – Following are the code – private void btnSign_Click(object sender, EventArgs e) { string sbase64 = richTextBox2.Text; byte[] bytes = System.Convert.FromBase64String(sbase64); PdfReader reader = new PdfReader("F:\\test1.pdf"); FileStream os = new FileStream("F:\\output.pdf", FileMode.Create); IExternalSignatureContainer external1 = new MyExternalSignatureContainer(bytes); MakeSignature.SignDeferred(reader, "Signature1", os, external1); reader.Close(); os.Close(); } private class MyExternalSignatureContainer : IExternalSignatureContainer { protected […]

Categories
Mastering Development

How to add CRL (offline) while injecting .p7s to a Pdf?

I inject p7s to a Pdf using code below: PdfWriter pdfWriter = new PdfWriter(“results/final1.pdf”); PdfDocument document = new PdfDocument(new PdfReader(“results/prepared1.pdf”), pdfWriter, new StampingProperties().UseAppendMode()); Stream output = new FileStream(“results/signed1.pdf”, FileMode.Create); ExternalInjectingSignatureContainer container2 = new ExternalInjectingSignatureContainer(_p7s); List<byte[]> crlCollection = new List<byte[]>(); crlCollection.Add(File.ReadAllBytes(@”ks/mycrls.crl”)); PdfSigner.SignDeferred(document, “Signature1”, output, container2); Found this I found this I tried it as below: ICrlClient […]