schorschii / Simple-Signer

Sign and certify PDF files on Linux with optional visual stamp using a .p12/.pfx certificate file
GNU General Public License v3.0
43 stars 8 forks source link

<class 'IndexError'>: list index out of range #8

Closed Penknife0915 closed 1 year ago

Penknife0915 commented 1 year ago

<class 'IndexError'>: list index out of range

I get this error after having clicked on "Sign" and having chosen where to save.

schorschii commented 1 year ago

Can you please execute simple-signer on the command line and post the output here?

Penknife0915 commented 1 year ago

$ simple-signer /usr/bin/simple-signer:109: DeprecationWarning: Support for PyQt5 is deprecated and will be removed in Pillow 10 (2023-07-01). Use PyQt6 or PySide6 instead. from PIL.ImageQt import ImageQt You can create a config file (*.stampinfo) with the following content to automate the signature process: {"rect": [69.0, 237.87985865724383, 414.0, 526.1342756183745], "page": 0} Traceback (most recent call last): File "/usr/bin/simple-signer", line 526, in DoSign signData = cms.sign(pdfData, dct, p12Data[0], p12Data[1], p12Data[2], 'sha256') File "/usr/local/lib/python3.9/dist-packages/endesive/pdf/cms.py", line 968, in sign return cls.sign( File "/usr/local/lib/python3.9/dist-packages/endesive/pdf/cms.py", line 678, in sign self.makepdf(prev, udct, algomd, zeros, cert, **params) File "/usr/local/lib/python3.9/dist-packages/endesive/pdf/cms.py", line 456, in makepdf sig["CN"] = cert.subject.get_attributes_for_oid( IndexError: list index out of range

schorschii commented 1 year ago

OK, the error is thrown here in the PDF signing library when trying to read the Common Name (CN) from your certificate to embed it into the optical stamp. It seems that your certificate does not have a Common Name, which is strange. Does the singing work without the optical stamp? Do you have another certificate for testing purposes?

Penknife0915 commented 1 year ago

It is signed when no stamp is added.

I am using an s/mime certificate and as far as I can see from the Firefox certificate store, there is no name in my certificate. I thought there was.

I can get a new certificate and fix the name issue and try again,

Does Simple Signer support s/mime?

schorschii commented 1 year ago

Yes, please get a new certificate with a Common Name. With this everything should work as expected.

Penknife0915 commented 1 year ago

I got the same error with the s/mime certificate from Sectigo.

https://extrassl.actalis.it/portal/uapub/freemail

The certificate generated from this link worked fine.