robrichards / xmlseclibs

A PHP library for XML Security
BSD 3-Clause "New" or "Revised" License
386 stars 180 forks source link

When Need To Set Attribute URI = '' #235

Open feader opened 2 years ago

feader commented 2 years ago

https://github.com/robrichards/xmlseclibs/blob/master/src/XMLSecurityDSig.php#L662 in XMLSecurityDSig.php, function addRefInternal, when (! $node instanceof DOMDocument) = false , it has no value, so make the URI='' is not exist , it show '', in my scene, i need it to be ''

so I add else for it image

what i need now is work

image

image

Mats commented 2 months ago

If I have understood your problem correctly; that you would like to have instead of you can pass in the option force_uri when signing:

// Sign using SHA-256 
$objDSig->addReference( 
    $doc,  
    XMLSecurityDSig::SHA256,  
    ['http://www.w3.org/2000/09/xmldsig#enveloped-signature'],
    ['force_uri' => true] // <----- this causes $force_uri to be true, which in turn results in the attribute URI="" being added
);