You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@santuario.apache.org by Matthias Niggemeier <m...@thias.de> on 2003/07/10 21:13:40 UTC
Validating UTF-16
Hi there!
Within my app, i´m downloading a UTF-16 coded xml-file.
But when I try to validate the signature, I get
"Could not find a signature node in passed in DOM document".
When I parse the same file coded as UTF-8, it works.
What can be wrong? (I am using VC++ on W2k).
Xerces returns with no error on both cases.
Greetings
Matthias
Re: AW: Validating UTF-16
Posted by Berin Lautenbach <be...@ozemail.com.au>.
Matthias,
The namespace URIs should be set up in the initialisation of the
library. the Signature node is found using a call to findDSIGNode.
Have you called
XSECPlatformUtils::Initialise();
anywhere?
Cheers,
Berin
Matthias Niggemeier wrote:
> Sorry, my mistake. It has nothing to do with utf-x, but
> with the namespace of the signature, i think. (tried utf-8
> and had the same problem)
>
> Assume the following xmlfile:
>
> <?xml version="1.0" encoding="UTF-8" standalone="no" ?>
> <MyRootTag xmlns:ds="http://www.w3.org/2000/09/xmldsig#"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:noNamespaceSchemaLocation="d:\myxsd.xsd">
> <Transaction>LOCK</Transaction>
> <Data/>
> <ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
> <ds:SignedInfo>
> <ds:CanonicalizationMethod
> Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments"/>
> <ds:SignatureMethod
> Algorithm="http://www.w3.org/2000/09/xmldsig#hmac-sha1"/>
> <ds:Reference URI="">
> <ds:Transforms>
> <ds:Transform
> Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/>
> </ds:Transforms>
> <ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
> <ds:DigestValue>3QgpKkQlTFkZA4Iy2ZfHD7gpU5A=</ds:DigestValue>
> </ds:Reference>
> </ds:SignedInfo>
> <ds:SignatureValue>vXCalSAoFFk1bVaqWP/gUk1ms/k=</ds:SignatureValue>
> </ds:Signature>
> </MyRootTag>
>
> I use the following code to validate the signature:
> xercesc::DOMDocument *doc = NULL;
> xercesc::DOMNode* root = NULL;
> bool bVerifyOK = false, bSaveOK = false;
> XSECProvider prov;
> DSIGSignature* sig = NULL;
> XERCES_CPP_NAMESPACE::DOMBuilder* builder = NULL;
> try
> {
> builder = static_cast<xercesc::DOMImplementationLS*>(
>
> xercesc::DOMImplementationRegistry::getDOMImplementation(X("LS"))
>
> )->createDOMBuilder(xercesc::DOMImplementationLS::MODE_SYNCHRONOUS,0);
>
> builder->setFeature(xercesc::XMLUni::fgDOMNamespaces, true);
>
> doc = builder->parseURI(X(_T("D:\test1.xml")));
>
> if (doc == NULL)
> {
> // oopsie
> }
> else // loaded
> {
> xercesc::DOMNode* signNode = NULL;
> sig = prov.newSignatureFromDOM(doc);
> sig->load();
> WinCAPICryptoKeyHMAC* hmacKey = new WinCAPICryptoKeyHMAC();
> hmacKey->setKey((unsigned char *) "secret", strlen("secret"));
> sig->setSigningKey(hmacKey);
> if (!sig->verify())
> {
> AfxMessageBox("No");
> }
> }
> }
> catch (...)
>
> I tried to follow the problem, it seems to be that the lib cannot find the
> signature tag (looks like it allways searches <signature>; how can I tell
> it to use namespace "ds"?
> (BTW: I am using VS6 and Xerces 2.3.0)
>
> greetings and thanks in advance
> Matthias
>
>
>>-----Ursprüngliche Nachricht-----
>>Von: Berin Lautenbach [mailto:berin@ozemail.com.au]
>>Gesendet: Freitag, 11. Juli 2003 08:54
>>An: security-dev@xml.apache.org
>>Betreff: Re: Validating UTF-16
>>
>>
>>Matthias,
>>
>>Could you attach the file in question?
>>
>>Cheers,
>> Berin
>>
>>
>>Matthias Niggemeier wrote:
>>
>>>Hi there!
>>>Within my app, i´m downloading a UTF-16 coded xml-file.
>>>But when I try to validate the signature, I get
>>>"Could not find a signature node in passed in DOM document".
>>>When I parse the same file coded as UTF-8, it works.
>>>What can be wrong? (I am using VC++ on W2k).
>>>Xerces returns with no error on both cases.
>>>
>>>Greetings
>>>Matthias
>>
>
AW: Validating UTF-16
Posted by Matthias Niggemeier <m...@thias.de>.
Sorry, my mistake. It has nothing to do with utf-x, but
with the namespace of the signature, i think. (tried utf-8
and had the same problem)
Assume the following xmlfile:
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<MyRootTag xmlns:ds="http://www.w3.org/2000/09/xmldsig#"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="d:\myxsd.xsd">
<Transaction>LOCK</Transaction>
<Data/>
<ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
<ds:SignedInfo>
<ds:CanonicalizationMethod
Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments"/>
<ds:SignatureMethod
Algorithm="http://www.w3.org/2000/09/xmldsig#hmac-sha1"/>
<ds:Reference URI="">
<ds:Transforms>
<ds:Transform
Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/>
</ds:Transforms>
<ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
<ds:DigestValue>3QgpKkQlTFkZA4Iy2ZfHD7gpU5A=</ds:DigestValue>
</ds:Reference>
</ds:SignedInfo>
<ds:SignatureValue>vXCalSAoFFk1bVaqWP/gUk1ms/k=</ds:SignatureValue>
</ds:Signature>
</MyRootTag>
I use the following code to validate the signature:
xercesc::DOMDocument *doc = NULL;
xercesc::DOMNode* root = NULL;
bool bVerifyOK = false, bSaveOK = false;
XSECProvider prov;
DSIGSignature* sig = NULL;
XERCES_CPP_NAMESPACE::DOMBuilder* builder = NULL;
try
{
builder = static_cast<xercesc::DOMImplementationLS*>(
xercesc::DOMImplementationRegistry::getDOMImplementation(X("LS"))
)->createDOMBuilder(xercesc::DOMImplementationLS::MODE_SYNCHRONOUS,0);
builder->setFeature(xercesc::XMLUni::fgDOMNamespaces, true);
doc = builder->parseURI(X(_T("D:\test1.xml")));
if (doc == NULL)
{
// oopsie
}
else // loaded
{
xercesc::DOMNode* signNode = NULL;
sig = prov.newSignatureFromDOM(doc);
sig->load();
WinCAPICryptoKeyHMAC* hmacKey = new WinCAPICryptoKeyHMAC();
hmacKey->setKey((unsigned char *) "secret", strlen("secret"));
sig->setSigningKey(hmacKey);
if (!sig->verify())
{
AfxMessageBox("No");
}
}
}
catch (...)
I tried to follow the problem, it seems to be that the lib cannot find the
signature tag (looks like it allways searches <signature>; how can I tell
it to use namespace "ds"?
(BTW: I am using VS6 and Xerces 2.3.0)
greetings and thanks in advance
Matthias
> -----Ursprüngliche Nachricht-----
> Von: Berin Lautenbach [mailto:berin@ozemail.com.au]
> Gesendet: Freitag, 11. Juli 2003 08:54
> An: security-dev@xml.apache.org
> Betreff: Re: Validating UTF-16
>
>
> Matthias,
>
> Could you attach the file in question?
>
> Cheers,
> Berin
>
>
> Matthias Niggemeier wrote:
> > Hi there!
> > Within my app, i´m downloading a UTF-16 coded xml-file.
> > But when I try to validate the signature, I get
> > "Could not find a signature node in passed in DOM document".
> > When I parse the same file coded as UTF-8, it works.
> > What can be wrong? (I am using VC++ on W2k).
> > Xerces returns with no error on both cases.
> >
> > Greetings
> > Matthias
>
Re: Validating UTF-16
Posted by Berin Lautenbach <be...@ozemail.com.au>.
Matthias,
Could you attach the file in question?
Cheers,
Berin
Matthias Niggemeier wrote:
> Hi there!
> Within my app, i´m downloading a UTF-16 coded xml-file.
> But when I try to validate the signature, I get
> "Could not find a signature node in passed in DOM document".
> When I parse the same file coded as UTF-8, it works.
> What can be wrong? (I am using VC++ on W2k).
> Xerces returns with no error on both cases.
>
> Greetings
> Matthias