add URI to Reference (internal ID)

1,098 views
Skip to first unread message

mus...@hotmail.com

unread,
Nov 12, 2010, 7:36:10 AM11/12/10
to xmlseclibs
Hi everybody,

I am trying to add URI="xxx" into the reference with no success. I saw
somewhere the options array('id_name' => 'ID')
but didn't work for me. Any help will appreciated?


this is what I used:
$objDSig->addReference($doc, XMLSecurityDSig::SHA1, array('http://
www.w3.org/2000/09/xmldsig#enveloped-signature'), array('id_name' =>
'ID'));

I tried on the basic example with:

<?xml version="1.0" encoding="UTF-8"?>
<!-- Basic XML example -->
<Root xmlns="urn:envelope" ID="123456">
<Value>
Hello, World!
</Value>
</Root>

thank you in advance

Rob Richards

unread,
Nov 12, 2010, 1:38:48 PM11/12/10
to xmlse...@googlegroups.com, mus...@hotmail.com
Since you want to sign the document element and not the entire document,
you first need to pass $doc->documentElement rather than $doc. This will
make it target the "Root" node. Also, if you want to preserve your
existing ID value, you need to also pass the "overwrite" option set to
false so that it will reuse "123456" rather than generating a new value.
So, the following code does what you expect:

$objDSig->addReference($doc->documentElement, XMLSecurityDSig::SHA1,
array('http://www.w3.org/2000/09/xmldsig#enveloped-signature'),
array('id_name' => 'ID', 'overwrite' => false));

Rob

mus...@hotmail.com

unread,
Nov 13, 2010, 4:22:26 AM11/13/10
to xmlseclibs
thanks that solved the problem.
Reply all
Reply to author
Forward
0 new messages