Read certificate from pdf

I use ITextSharp to read certificate information from a digitally signed document.

The ITextSharp.Text.Pdf.PdfPKCS7 class provides three properties:

  • Certificates (as a list)
  • SignCertificate (as a separate entity)
  • SignCertificateChain (as a list)

How can I combine these three properties to get all the information about a single certificate?

I could show the whole path to the certificate (all nested certificates).

+4
source share
1 answer

Certificates gives you a list without any special order, including certificates that were not used for the main signature.

SignCertificate gives you a valid SignCertificate Certificate.

SignCertificateChain provides a list in which the first certificate is SignCertificate, the next is the certificate of the instance that issued the SignCertificate, the next is the certificate of the instance that issued the previous certificate, and so on. This may return fewer certificates than Certificates , because only the certificates used for the primary signature will be returned.

Therefore, you do not need to β€œcombine” the properties to show the path to the certificate, you just need SignCertificateChain. Please note that your question is not entirely clear:

'all information about one certificate

contradicts

'show all certificate path (all nested certificates)'

If you want to visualize the chain indicated in the signature certificate, you need to look at no more than one certificate (unless the certificate itself was signed by itself, in this case there will be only one element in the chain).

+2
source

Source: https://habr.com/ru/post/1434841/


All Articles