Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 572865
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T13:39:48+00:00 2026-05-13T13:39:48+00:00

I use iTextSharp to sign a PDF file. But Adobe Reader cannot verify my

  • 0

I use iTextSharp to sign a PDF file. But Adobe Reader cannot verify my signature. I use SHA-2 test certificate (I tried also SHA-1) generated by certification authority. I have installed root certificate for test certificates of this authority.

public static void SignHashed(X509Certificate2 card, Stream input, Stream output) {
    Org.BouncyCastle.X509.X509CertificateParser cp = new Org.BouncyCastle.X509.X509CertificateParser();
    Org.BouncyCastle.X509.X509Certificate[] chain = new Org.BouncyCastle.X509.X509Certificate[] { cp.ReadCertificate(card.RawData) };

    PdfReader reader = new PdfReader(input);
    PdfStamper stp = PdfStamper.CreateSignature(reader, output, '\0');
    PdfSignatureAppearance sap = stp.SignatureAppearance;
    sap.SignDate = DateTime.Now;
    sap.SetCrypto(null, chain, null, PdfSignatureAppearance.WINCER_SIGNED);
    sap.Reason = "Testování";
    sap.Location = "Praha";
    sap.Acro6Layers = true;
    sap.Render = PdfSignatureAppearance.SignatureRender.GraphicAndDescription;
    PdfSignature dic = new PdfSignature(PdfName.ADOBE_PPKMS, PdfName.ADBE_PKCS7_SHA1);
    dic.Date = new PdfDate(sap.SignDate);
    dic.Name = PdfPKCS7.GetSubjectFields(chain[0]).GetField("CN");
    if (sap.Reason != null) dic.Reason = sap.Reason;
    if (sap.Location != null) dic.Location = sap.Location;
    sap.CryptoDictionary = dic;
    int csize = 4000;
    Hashtable exc = new Hashtable();
    exc[PdfName.CONTENTS] = csize * 2 + 2;
    sap.PreClose(exc);

    System.Security.Cryptography.HashAlgorithm sha = new System.Security.Cryptography.SHA1CryptoServiceProvider();

    Stream s = sap.RangeStream;
    int read = 0;
    byte[] buff = new byte[8192];
    while ((read = s.Read(buff, 0, 8192)) > 0) {
        sha.TransformBlock(buff, 0, read, buff, 0);
    }
    sha.TransformFinalBlock(buff, 0, 0);
    byte[] pk = SignMsg(sha.Hash, card, false);

    byte[] outc = new byte[csize];

    PdfDictionary dic2 = new PdfDictionary();

    Array.Copy(pk, 0, outc, 0, pk.Length);

    dic2.Put(PdfName.CONTENTS, new PdfString(outc).SetHexWriting(true));
    sap.Close(dic2);
}

Does anyone knows better solution for sign a PDF?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T13:39:49+00:00Added an answer on May 13, 2026 at 1:39 pm

    Adobe Reader can’t verify the sign because need to import the CA chain to Adobe Reader in Advanced menú, option “Manage Trusted Identities”.
    Good luck!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Use case: 3rd party application wants to programatically monitor a text file being generated
I use Firebug and the Mozilla JS console heavily, but every now and then
I use a stream reader to import some data and at the moment I
'''use Jython''' import shutil print dir(shutil) There is no, shutil.move, how does one move
Use case: A does something on his box and gots stuck. He asks B
We use a data acquisition card to take readings from a device that increases
I use rsync to synchronize files to Windows clients in a server agnostic way.
I use emacs to edit my xml files (nxml-mode) and the files were generated
I use the VS2008 command prompt for builds, TFS access etc. and the cygwin
We use QuickBooks for financial management, and feed it from a variety of sources.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.