[xmlsec] Question about loading external DTD

Meg Morgan meg at votehere.net
Thu Feb 6 13:23:28 PST 2003


I'll try to phrase my question better today:

I am not using the command line utility, I am generating encrypted
data in memory and then attempting to decrypt it.  It does decrypt
fine, but I get the annoying "validity error" message in my output.
I get this message before I get a chance to tell it where my DTD
is.  How do I either:

1) put the dtd URL directly into the encrypted data so it will
know where to find it, or
2) suppress the validity error until I can validate it with the
external dtd.


Here is a code snippet:

xmlDocPtr doc = NULL;
xmlDtdPtr dtd = NULL;
xmlNodePtr cur;

std::string str_edata(encrypted_data);  // passed in as argument to my function
int len = str_edata.length();
doc = xmlParseMemory((char *)encrypted_data, len);
if (doc == NULL) {
   result = -1;    
}
else
{
  cur = xmlDocGetRootElement(doc);
  if (cur == NULL) {
     result = -1;    
   }
   else
   {
      char * dtdfile = "http://.../my.dtd";
      dtd = xmlParseDTD(NULL, (const xmlChar*)dtdfile);
      if (dtd != NULL)
      {
         xmlValidCtxt vctx;
         memset(&vctx, 0, sizeof(vctx));
         if ( (xmlValidateDtd(&vctx, doc, dtd)) != 1)
         {
            result = -1;
         }
      }
      else
      {
         result = -1;
      }
   }
}

Aleksey Sanin wrote:
> 
> In your example "xmlns" is not an attribute but namespace declaration.
> It's very difficult to tell what exactly is wrong with your dtd and file.
> You might try to validate your file against the dtd using LibXML2
> xmllint utility first. It might give you some more information on
> what's wrong.
> 
> Aleksey
> 
> Meg Morgan wrote:
> 
> >Hello,
> >
> >I have upgraded to libxmlsec-0.0.12.win32 and all of the
> >other new windows binaries.  I found the code in xmlsec.c
> >which relates to the external dtd when using the command
> >line utility.
> >
> >When I encrypt data, for example, I get something like
> >this:
> >
> ><EncryptedData xmlns="http://www.w3.org/2001/04/xmlenc#">
> >.
> >.
> >.
> ></EncryptedData>
> >
> >When I decrypt, it complains that validation failed, and
> >points to the end of that line (xmlend#).  I think I understand
> >how to indicate the external dtd, but how do I get it to either
> >ignore this attribute, or not put it there in the first place?
> >
> >I appreciate your help.
> >meg
> >
> >
> >

-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Meg Morgan                           425/450-2754
meg at votehere.net                   http://www.votehere.net



More information about the xmlsec mailing list