Simple-Signer icon indicating copy to clipboard operation
Simple-Signer copied to clipboard

Signing encrypted or write protected documents - `KeyError: 'password'`

Open mosuem opened this issue 2 months ago • 2 comments

Traceback (most recent call last):
  File "/.../Simple-Signer-1.7.0/venv/lib/python3.12/site-packages/simple_signer/simple_signer.py", line 603, in DoSign
    signData = cms.sign(pdfData, dct, p12Data[0], p12Data[1], p12Data[2], 'sha256')
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/.../Simple-Signer-1.7.0/venv/lib/python3.12/site-packages/endesive/pdf/cms.py", line 1022, in sign
    return cls.sign(
           ^^^^^^^^^
  File "/.../Simple-Signer-1.7.0/venv/lib/python3.12/site-packages/endesive/pdf/cms.py", line 673, in sign
    rc = prev.decrypt(udct["password"])
                      ~~~~^^^^^^^^^^^^
KeyError: 'password'

When trying to sign.

openssl pkcs12 -in /home/.../keyStore.p12 -info -noout -nokeys

shows that the password is correct.

mosuem avatar Oct 10 '25 09:10 mosuem

Your PDF is encrypted, right? This error is not about the cert password, but the PDF password. Signing encrypted PDFs is currently not supported.

schorschii avatar Oct 11 '25 09:10 schorschii

Thanks! It's not password encrypted, but the PDF seems to have editing disabled. I also can't write text on it in Adobe.

mosuem avatar Oct 13 '25 09:10 mosuem