py-pdf / pypdf

A pure-python PDF library capable of splitting, merging, cropping, and transforming the pages of PDF files
https://pypdf.readthedocs.io/en/latest/
Other
8.31k stars 1.41k forks source link

Add digital signature support #302

Closed alexis-via closed 2 years ago

alexis-via commented 8 years ago

AFAIK, there is still no opensource Python lib to generate a signed PDF. This is becoming more and more important with the adoption of electronic invoicing ; some countries or administration now require signed PDF to consider the invoice as valid.

There was an old bug report about it https://github.com/mstamy2/PyPDF2/issues/101 ; but it has been closed and the author of the bug developed a wrapper on the opensource Java lib that signs PDF called jPDFsign http://private.sit.fraunhofer.de/~stotz/software/jpdfsign/ His python wrapper is here: https://github.com/ovnicraft/signer

But I think we really need a pure-python lib to generate a signed PDF... and PyPDF2 would be the ideal place to have this feature.

nitrocode commented 4 years ago

Probably wouldn't be too difficult to add.

I'd like the ability to add a signature field to an existing PDF and be able to sign an existing PDF's signature field.

  <<
    /T (My Signature)
    /Subtype /Widget
    /FT /Sig
    /F 4
    /Q 1
    /MK << /BC [] >>
  >>

From How to attach a digital signature to my pdf created by xetex?

Other references:

joelricci commented 4 years ago

I'm trying to find a library with PAdES support. There is https://github.com/m32/endesive, which seems to be work in progress, but it's unclear to me wether it supports PAdES and in that case which profiles are supported.

MartinThoma commented 2 years ago

pyHanko supports adding digital siguatures. I spoke a bit with the project members: https://github.com/MatthiasValvekens/pyHanko/discussions/127

I like the feature, but I also don't see the need to add it directly to PyPDF2. We have a couple of other topics/bugs in PyPDF2 which we should improve and pyHanko could be used in combination with PyPDF2.

For that reason, I would close this issue as "not in 2022". If anybody still feels we need it, we can open it in 2023 again. Are there any objections?

alexis-via commented 2 years ago

Yes, let's close it!

MatthiasValvekens commented 2 years ago

I'm trying to find a library with PAdES support. There is https://github.com/m32/endesive, which seems to be work in progress, but it's unclear to me wether it supports PAdES and in that case which profiles are supported.

For the record, pyHanko supports all PAdES baseline profiles out of the box :).

MartinThoma commented 2 years ago

I'm closing this issue for the moment. It's important to get everything right when dealing with cryptography - partial solutions are likely doing more harm than good.

If we get more active developers / active contributors who feel very confident in that topic, we can discuss it again.

For the moment, please have a look at pyHanko :-)