MatthiasValvekens / pyHanko

pyHanko: sign and stamp PDF files
MIT License
486 stars 71 forks source link

Loading certificate file and key from inputstream or bytearray instead of file name #160

Closed MatthiasValvekens closed 1 year ago

MatthiasValvekens commented 1 year ago

From discussion #158 started by @lombaardcj007.

Original post

Originally posted by **lombaardcj007** September 27, 2022 Is it possible to call `SimpleSigner.load()` with a bytearray or string that represents the contents of the `key_file` and `cert_file` I want to keep the keys in a database instead of stored onto disk. Sample code to sign PDF document: ``

Maintainer comment

Of course that's possible, but the current API doesn't really expose that functionality in a convenient way, since the caller has to know a great deal more about how their keys/certs/... are encoded than they would if they were loading them from files. It would be better to expose a version of all the load_XYZ_from_pemder(...) functions that works with binary IO handles instead of file names. Since that's a fairly trivial enhancement, it shouldn't be hard to get it into the next release.