[Pyxmlsec-devel] xmlsec in python

Dieter Maurer dieter at handshake.de
Wed Feb 22 07:56:31 CET 2012


Dear Dolf,

You wrote:
> I am trying to decrypt an xml message in python using PyXMLSec.
> I have found the examples on
> http://pyxmlsec.labs.libre-entreprise.org/index.php?section=examples&id=11
> and accordingly did the following, but am receiving errors from the c
> library, which I really don't understand.
> ...
> key=xmlsec.keyReadBinaryFile(xmlsec.keyDataRsaId(),private_key_file)
> '''
> func=xmlSecKeyDataBinRead:file=keysdata.c:line=349:obj=unknown:subj=id->binRead
> != NULL:error=100:assertion:
> func=xmlSecKeyReadBuffer:file=keys.c:line=1190:obj=rsa:subj=xmlSecKeyDataBinRead:error=1:xmlsec
> library function failed:
> func=xmlSecKeyReadBinaryFile:file=keys.c:line=1247:obj=rsa:subj=xmlSecKeyReadBuffer:error=1:xmlsec
> library function failed:filename=my.private.key
> '''

I agree that the problem messages from "xmlsec" are mostly helpful
for the developer (or other people who have its source at hand
and are willing to consult it).

In your case, the function "xmlSecKeyDataBinRead" (called from
"xmlSecKeyReadBinaryFile" via intermediate "xmlSecKeyReadBuffer"
-- i.e. the problem message is similar to a Python traceback with
the most recent call at the top) is obviously unhappy
with your key data: Something which should be "NULL" is not.

If you are using "xmlsec" on a 64 bit architecture, then this
might result from "xmlsec" and "pyxmlsec" being compiled with
incompatible compile time options. The archive of this mailing
list contains a patch for "pyxmlsec" to fix this problem.

If not, I would guess that for some reason, your private key file
does not contain a binary RSA key. Maybe, it uses another format, e.g.
the "PEM" format. Have a look at the file content: the "PEM" format
is human readable (it essentially contains the base64 encoded key)
while a true binary key is unreadable.


--
Dieter


More information about the Pyxmlsec-devel mailing list