You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
xmlsec.Error: (1, 'cannot load key') while loading the private key #328
I have a X509 private in a file and trying to use the below code to load the private key. However i am getting the xmlsec.Error: (1, 'cannot load key'). I tried multiple ways. nothing is working and more over the error message is not detailed enough to try other options.
Any suggestions are greatly appreciated. Thank you.
with open('private_key.pem', 'rb') as key_file:
key_data = key_file.read()
xmlsec.Key.from_memory(key_data, xmlsec.constants.KeyDataFormatPem)
Activity
tpanum commentedon Oct 14, 2024
I am experiencing a similar issue. I have a
.p12-certificate that I have transformed to x509 using OpenSSL.$ openssl x509 -in cert.pem -text -nooutruns without issues. However, I can't load the file withxmlsec.jimjag commentedon Nov 5, 2024
Are we sure that this is an issue w/ us and not the underlying lib itself?
fenuks commentedon Nov 14, 2025
I also have this problem.
raises
Error: (1, 'cannot read key').openssl rsa -in private.key -textloads this key without problem.
Tested on ArchLinux, python 3.13.7, OpenSSL 3.6.0.
EDIT:
It's a mistake on my part. Using
xmlsec.constants.KeyDataFormatPemfixes theproblem.