<div dir="ltr"><div>Hi all,<br><br>Please check anything i am doing wrong in the key buffer creation. simply I am directly copying the key from the private key file generated using openssl. I have attached sample key file(dtls.key) , where i have taken the key.<br>
<br></div><div>Please help me to solve this issue.<br></div><div>
<br><br> const xmlSecByte *keybuf = "MIIBOwIBAAJBALe2myLsvZaYVDcZAkaHfaYnwlojm7ebRHGuLGUvYXHgmdMU9LLT6cMABq2me+ioQLhB0+KY4Nth91NG52spEtECAwEAAQJAMKWQCv15bolDs5tRuO9j3D2m/0tyjnn0881VQC39tbN6w+tCVhUHPEy+3l/jf7b/xkuIcbgV2voXVEVFjHmwCQIhAOTF+LdlVZ/TbIEM+GRTaYQQEXz0NjWWIARxDv6OWvdzAiEAzZPK3ZqQtXw3/E2HU6DGBFxB8S92PGk5EFKWaUtG06sCIQC+Cx9j6lBI5u9Z/RZS8V/UDy0X6h8mQMH0Lp9QI525tQIgaslZuNFAWDWlc1bmc+dw1PUDgAByf6D89mCgJyPmL68CIQCmkdwn7cuWI4GlVJnpDZ2iHZjeiih3oVR73/WquuyJqw==";<br>
xmlSecSize keysize = strlen(keybuf);<br><br><br> assert(tmpl_file);<br> assert(key_file);<br><br> /* load template */<br> doc = xmlParseFile(tmpl_file);<br> if ((doc == NULL) || (xmlDocGetRootElement(doc) == NULL)){<br>
fprintf(stderr, "Error: unable to parse file \"%s\"\n", tmpl_file);<br> goto done;<br> }<br><br> /* find start node */<br> node = xmlSecFindNode(xmlDocGetRootElement(doc), xmlSecNodeSignature, xmlSecDSigNs);<br>
if(node == NULL) {<br> fprintf(stderr, "Error: start node not found in \"%s\"\n", tmpl_file);<br> goto done;<br> }<br><br> /* create signature context, we don't need keys manager in this example */<br>
dsigCtx = xmlSecDSigCtxCreate(NULL);<br> if(dsigCtx == NULL) {<br> fprintf(stderr,"Error: failed to create signature context\n");<br> goto done;<br> }<br><br><br> <br> /* load private key, assuming that there is not password */<br>
<br> dsigCtx->signKey = xmlSecCryptoAppKeyLoadMemory(keybuf,keysize,xmlSecKeyDataFormatPem, NULL, NULL, NULL);<br> if(dsigCtx->signKey == NULL) {<br> fprintf(stderr,"Error: failed to load private pem key from \"%s\"\n", key_file);<br>
goto done;<br> }<br><br></div><div>Thanks,<br></div><div>Venkat.<br></div><div><br></div><br><br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Apr 2, 2013 at 11:38 PM, Aleksey Sanin <span dir="ltr"><<a href="mailto:aleksey@aleksey.com" target="_blank">aleksey@aleksey.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">You will need to debug what's going on at the openssl level. If I would<br>
guess then I would think you didn't load the key into memory correctly.<br>
<br>
Aleksey<br>
<div class="im"><br>
On 4/2/13 8:00 AM, Venkataragavan Vijayakumar wrote:<br>
> Hi All,<br>
><br>
> Previously I have used the xmlSecCryptoAppKeyLoad() API to load the Key<br>
> file in the PEM format , it worked fine, but when i start to use<br>
> xmlSecCryptoAppKeyLoadMemory() with the same content in the key file is<br>
> given as input as buffer, it given error as<br>
><br>
><br>
> func=xmlSecOpenSSLAppKeyLoadBIO:file=app.c:line=263:obj=unknown:subj=PEM_read_bio_PrivateKey<br>
> and PEM_read_bio_PUBKEY:error=4:crypto library function<br>
> failed:<br>
><br>
> func=xmlSecOpenSSLAppKeyLoadMemory:file=app.c:line=205:obj=unknown:subj=xmlSecOpenSSLAppKeyLoadBIO:error=1:xmlsec<br>
> library function failed:<br>
><br>
><br>
</div>> *<br>
><br>
> code used like this*:<br>
<div class="im">><br>
> dsigCtx->signKey =<br>
> xmlSecCryptoAppKeyLoadMemory(keybuf,keysize,xmlSecKeyDataFormatPem,<br>
> NULL, NULL, NULL);<br>
> if(dsigCtx->signKey == NULL) {<br>
> fprintf(stderr,"Error: failed to load private pem key from<br>
> \"%s\"\n", key_file);<br>
> goto done;<br>
> }<br>
><br>
> Please help me to resolve this issue.<br>
><br>
> Thanks,<br>
> Venkat.<br>
><br>
><br>
><br>
</div>> _______________________________________________<br>
> xmlsec mailing list<br>
> <a href="mailto:xmlsec@aleksey.com">xmlsec@aleksey.com</a><br>
> <a href="http://www.aleksey.com/mailman/listinfo/xmlsec" target="_blank">http://www.aleksey.com/mailman/listinfo/xmlsec</a><br>
><br>
</blockquote></div><br></div>