[xmlsec] Question with code for xmlencryption

Govind Krishnamurthi govs23 at hotmail.com
Tue Apr 27 11:38:08 PDT 2004


Hi Aleksey,
I am trying to dynamically create a template and encrypt an xml document. I 
looked at your tutorial.

In my example, I  did not want to create a separate session key and wanted 
to use the keypair in the .pem file. This is what I did.
First I initialized key manager, loaded the key, set the key name to the 
keyfile and then added the key to the key manager.
Since the document did not have a template,  I created a template 
dynamically. Here I created the encryption template , created the 
CipherValue node KeyInfo node etc then added the Keyname. I did not add the 
encrypted key node as I wasn't using a session key
Finally, I created the encryption context using the key manager.
Then called xmlSecEncCtxXmlEncrypt function. I get the following error.


func=xmlSecKeysMngrGetKey:file=keys.c:line=1364:obj=unknown:subj=xmlSecKeysMngrFindKey:error=1:xmlsec 
library function failed:
func=xmlSecEncCtxEncDataNodeRead:file=xmlenc.c:line=885:obj=unknown:subj=unknown:error=45:key 
is not found:
func=xmlSecEncCtxXmlEncrypt:file=xmlenc.c:line=375:obj=unknown:subj=xmlSecEncCtxEncDataNodeRead:error=1:xmlsec 
library function failed:
Unable to encrypt xmlfile
encryption failed

I then tried to not use a manager while creating the encCtx and just try to 
set the key in encCtx->encKey from the keyfile using xmlSecCryptoAppKeyLoad.

./xmlencrypt mysample.xml mykey.pem
func=xmlSecEncCtxEncDataNodeRead:file=xmlenc.c:line=885:obj=unknown:subj=unknown:error=45:key 
is not found:
func=xmlSecEncCtxXmlEncrypt:file=xmlenc.c:line=375:obj=unknown:subj=xmlSecEncCtxEncDataNodeRead:error=1:xmlsec 
library function failed:
Unable to encrypt xmlfile
encryption failed

As a matter of curiosity I tried to modify the code to take deskey.bin as 
the input keyfile (and without the keymanager) but using the same dynamic 
template creation routine and it worked fine.

My question is is there something wrong in the template I am creating or is 
something else wrong?

Thanks in advance,
Govind.

_________________________________________________________________
Get rid of annoying pop-up ads with the new MSN Toolbar – FREE! 
http://toolbar.msn.com/go/onm00200414ave/direct/01/




More information about the xmlsec mailing list