Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prefix "ds" in Signature node. #13

Closed
GoogleCodeExporter opened this issue Mar 31, 2015 · 13 comments
Closed

Prefix "ds" in Signature node. #13

GoogleCodeExporter opened this issue Mar 31, 2015 · 13 comments

Comments

@GoogleCodeExporter
Copy link

I had problems with my signature validations by the prefix "ds", so I made 
changes to indicate whether the firm is required prefix or not.


Attachment changes made.


require(dirname(__FILE__) . '/../xmlseclibs.php');

if (file_exists(dirname(__FILE__) . '/sign-basic-test.xml')) {
    unlink(dirname(__FILE__) . '/sign-basic-test.xml');
}

$doc = new DOMDocument(); 
$doc->formatOutput = FALSE; 
$doc->preserveWhiteSpace = TRUE;

$semilla = getSeed();
$xml = 
"<getToken>\n\t<item>\n\t\t<Semilla>$semilla</Semilla>\n\t</item>\n</getToken>";

$doc->loadXML($xml);
$objDSig = new XMLSecurityDSig(FALSE);
//die;
$objDSig->setCanonicalMethod(XMLSecurityDSig::C14N);
$options['prefix'] = '';
$options['prefix_ns'] = '';
$options['force_uri'] = TRUE;
$options['id_name'] = 'ID';
$objDSig->addReference($doc, XMLSecurityDSig::SHA1, 
array(XMLSecurityDSig::TR_ENV_SIG), $options);

$objKey = new XMLSecurityKey(XMLSecurityKey::RSA_SHA1, 
array('type'=>'private'));
$pfx = file_get_contents(dirname(__FILE__) . "/file.pfx");
openssl_pkcs12_read($pfx, $key, "pass");
$objKey->loadKey($key["pkey"]);
$objDSig->add509Cert($key["cert"]);
$objDSig->sign($objKey, $doc->documentElement);

$doc->save(dirname(__FILE__) . '/sign-basic-test.xml');

Original issue reported on code.google.com by atiruz on 20 Sep 2012 at 9:35

Attachments:

@robrichards
Copy link
Owner

The constructor for the XMLSecurityDSig now takes an optional argument for defining the prefix, if any, to be used. When not passed it uses default behavior. When set to an empty string or null, it won't use a prefix, otherwise it will use the prefix passed in. See the xml-sign-prefix.phpt test for an example

@akshaykmr286
Copy link

Wdf..
Not helpfull..Y do u suggest nonsense..

@rodrigoferra
Copy link

To remove the prefix you can pass a new prefix as parameter to class.
$objDSig = new XMLSecurityDSig('');

@langaro
Copy link

langaro commented Mar 10, 2019

@rodrigoferra Thank you!

@falinhares
Copy link

Thanks @rodrigoferra for the tip. Solved my problem here!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants