Yubico / yubikey-manager-qt

Cross-platform application for configuring any YubiKey over all USB interfaces.
https://developers.yubico.com/yubikey-manager-qt/
BSD 2-Clause "Simplified" License
237 stars 29 forks source link

Invalid password or PKCS12 data #354

Open Torxed opened 10 months ago

Torxed commented 10 months ago

Steps to reproduce

Generate a CSR, sign it, run openssl pkcs12 -export -out test.p12 -inkey test.key.pem -in ssl/newcerts/1000.pem -certfile ssl/cacert.pem And then try to import the .p12 in ykman-gui.

Expected result

It appears to actually complete the import, as I have it loaded: screenshot

However the stacktrace below also happens.

Actual results

Traceback (most recent call last):
  File "/usr/lib/python3.11/site-packages/ykman/util.py", line 51, in _parse_pkcs12
    key, cert, cas = pkcs12.load_key_and_certificates(
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/cryptography/hazmat/primitives/serialization/pkcs12.py", line 157, in load_key_and_certificates
    return ossl.load_key_and_certificates_from_pkcs12(data, password)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/cryptography/hazmat/backends/openssl/backend.py", line 1607, in load_key_and_certificates_from_pkcs12
    pkcs12 = self.load_pkcs12(data, password)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/cryptography/hazmat/backends/openssl/backend.py", line 1636, in load_pkcs12
    raise ValueError("Invalid password or PKCS12 data")
ValueError: Invalid password or PKCS12 data

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "qrc:///py/yubikey.py", line 78, in wrapped
    return f(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^
  File "qrc:///py/yubikey.py", line 749, in piv_can_parse
    parse_certificates(data, password=None)
  File "/usr/lib/python3.11/site-packages/ykman/util.py", line 129, in parse_certificates
    return _parse_pkcs12(data, password)[1]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/ykman/util.py", line 58, in _parse_pkcs12
    raise InvalidPasswordError(e)
ykman.util.InvalidPasswordError: Invalid password or PKCS12 data
Cannot convert: QVariant(std::nullptr_t, (nullptr))