![]() This.hashAlgorithm = DigestAlgorithms.GetDigest(DigestAlgorithms. Public MyExternalSignature2(String hashAlgorithm) MyMakeSignature.SignDetached(appearance, externalSignature, chain, null, null, tsc, 0, CryptoStandard.CADES) Įxternal signature implementation (class MyExternalSignature2): class MyExternalSignature2 : IExternalSignature IExternalSignature externalSignature = new MyExternalSignature2("SHA-1") TSAClientBounc圜astle tsc = new TSAClientBounc圜astle("", "", "") PdfSignatureAppearance appearance = stamper.SignatureAppearance Īppearance.SignatureGraphic = Image.GetInstance("img.png") // visual imageĪppearance.SetVisibleSignature(new Rectangle(50, 50, 250, 100), pdfReader.NumberOfPages, "Signature") Īppearance.SignatureRenderingMode = _AND_DESCRIPTION iTextPDF Signature: how to not show signature fields, but show an image. What I would like to do is to display just the sign of the signer and not the text saying DIGI. PdfStamper stamper = PdfStamper.CreateSignature(pdfReader, signedPdf, '\0', null, false) Im tryng to sign digitally a pdf using iText and I achieved successfully helped by this example. Stream signedPdf = new FileStream("signed.pdf", FileMode.Create) PdfReader pdfReader = new PdfReader("original.pdf") Org.Bounc圜509Certificate chain = new Org.Bounc圜509Certificate X509CertificateParser certParse = new Org.Bounc圜509CertificateParser() X509Certificate2 cert = new X509Certificate2() Ĭert.Import("cert.cer") // certificate obtained from smart card When i sign PDF with Adobe Reader, at step 6, the third hash is 32 bytes long.įrom Smart Card's perspective i do the same steps with both Acrobat and iText, but with iText the signature is invalid, what could be wrong ? that third hash is finally sent to a Smart Card to compute a.that second hash is hashed again inside of external signature object.Varies, why? might not be a hash after all?) that Hash + some other properties are hashed again (number of bytes.Byte range of that field is hashed (by default produces 20 bytes for sha-1, tried 32 bytes with sha-256 too). ![]() new PDF with empty signature field is created.So I understood the procedure of signing as the following: and use this hash to compute a signatureīyte extSignature = externalSignature.Sign(sh) Then, according to "sign" method in message the message you want to be hashed and signed" // looks like externalSignature.Sign() should make another hash out of "sh" gets the second hash or is it not a hash at all ?īyte sh = sgn.getAuthenticatedAttributeBytes(hash, ocsp, crlBytes, sigtype) I've looked at MakeSignature.cs code for reference and what is does: Stream data = signatureAppearance.GetRangeStream() īyte hash = DigestAlgorithms.Digest(data, hashAlgorithm) I've been toying with iTextSharp 5.5.7 for a while and can't find the right way to make a valid digital signature for PDF from Smart Card - Adobe Reader always says its signed by and unknown and can't decode signatures' DER data. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |