Skip to content

Error: (1, 'cannot read key') #342

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
danielmendez14 opened this issue Mar 3, 2025 · 1 comment
Open

Error: (1, 'cannot read key') #342

danielmendez14 opened this issue Mar 3, 2025 · 1 comment

Comments

@danielmendez14
Copy link

danielmendez14 commented Mar 3, 2025

Hi! I have a problem, when I do this:

key = xmlsec.Key.from_file(p12_path, xmlsec.constants.KeyDataFormatPkcs12, password=pass)

The file .p12 I can extract the private key and certificate whit this:

private_key, certificate, additional_certs = pkcs12.load_key_and_certificates(p12_data, clave.encode("utf-8"))
print("🔐 Private key:", private_key)

And then it print: <cryptography.hazmat.bindings._rust.openssl.rsa.RSAPrivateKey object at 0x73e07a4763d0>

Then, the path is fine, and the file also. What do I am doing wrong? Help, thanks

@andres-holvi
Copy link

andres-holvi commented May 5, 2025

I can confirm this error is happening.

Using the same xmlsec.Key.from_file code to load a p12 key works for python-xmlsec==1.3.14 and xmlsec==1.3.6 (using Alpine linux 3.20), but it does not work for python-xmlsec==1.3.15 and xmlsec==1.3.7 (using Alpine linux 3.21).

Getting a Error: (1, 'cannot read key') error message.

Not sure how to determine if this is an issue with python-xmlsec or xmlsec itself, but happy to help if pointed in the right direction.

Edit: xmlsec error seems to come from this line

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants