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

KeyInfo empty #217

Open
NerijusNoreika opened this issue Sep 30, 2020 · 1 comment
Open

KeyInfo empty #217

NerijusNoreika opened this issue Sep 30, 2020 · 1 comment

Comments

@NerijusNoreika
Copy link

NerijusNoreika commented Sep 30, 2020

Upon signing the XML with xmlseclibs, my KeyInfo holds no data (no exponent, no modulus).

Here is the code:

` $doc = new \DOMDocument();
$doc->load('./keys/data.xml');

$sig = new XMLSecurityDSig();
try {
$sig->setCanonicalMethod(XMLSecurityDSig::EXC_C14N);
} catch (Exception $e) {
echo $e->getMessage();
}
try {
$privateKey = new XMLSecurityKey(XMLSecurityKey::RSA_SHA1, ['type' => 'private']);
$privateKey->passphrase = 'testtest';
} catch (Exception $e) {
echo $e->getMessage();
}

try {
$privateKey->loadKey('file://keys/testKey.pem');
} catch (Exception $e) {
echo $e->getMessage();
}

$sig->sign($privateKey);
$sig->add509Cert('file://keys/testCert.pem');
$sig->appendSignature($doc->getElementsByTagName('authenticationRequest')[0], false);
$doc->save('./keys/test.xml'); `

Signed document:
<authentication:authenticationRequest xmlns:authentication="http://www.epaslaugos.lt/services/authentication" xmlns:dsig="http://www.w3.org/2000/09/xmldsig#" xmlns:ns3="http://www.w3.org/2001/10/xml-exc-c14n#" id="uniqueNodeId"><authentication:pid>VSID000000000113</authentication:pid><authentication:serviceTarget>citizen</authentication:serviceTarget><authentication:authenticationProvider>auth.lt.identity.card</authentication:authenticationProvider><authentication:authenticationProvider>auth.lt.bank</authentication:authenticationProvider><authentication:authenticationProvider>auth.signatureProvider</authentication:authenticationProvider><authentication:authenticationProvider>auth.login.pass</authentication:authenticationProvider><authentication:authenticationProvider>auth.lt.government.employee.card</authentication:authenticationProvider><authentication:authenticationProvider>auth.stork</authentication:authenticationProvider><authentication:authenticationProvider>auth.tsl.identity.card</authentication:authenticationProvider><authentication:authenticationAttribute>lt-personal-code</authentication:authenticationAttribute><authentication:authenticationAttribute>lt-company-code</authentication:authenticationAttribute><authentication:userInformation>firstName</authentication:userInformation><authentication:userInformation>lastName</authentication:userInformation><authentication:userInformation>companyName</authentication:userInformation><authentication:userInformation>email</authentication:userInformation><authentication:userInformation>address</authentication:userInformation><authentication:postbackUrl>https://localhost/</authentication:postbackUrl><authentication:customData>correlationData</authentication:customData></authentication:authenticationRequest>

Output:

<?xml version="1.0"?> <authentication:authenticationRequest xmlns:authentication="http://www.epaslaugos.lt/services/authentication" xmlns:dsig="http://www.w3.org/2000/09/xmldsig#" xmlns:ns3="http://www.w3.org/2001/10/xml-exc-c14n#" id="uniqueNodeId"><authentication:pid>VSID000000000113</authentication:pid><authentication:serviceTarget>citizen</authentication:serviceTarget><authentication:authenticationProvider>auth.lt.identity.card</authentication:authenticationProvider><authentication:authenticationProvider>auth.lt.bank</authentication:authenticationProvider><authentication:authenticationProvider>auth.signatureProvider</authentication:authenticationProvider><authentication:authenticationProvider>auth.login.pass</authentication:authenticationProvider><authentication:authenticationProvider>auth.lt.government.employee.card</authentication:authenticationProvider><authentication:authenticationProvider>auth.stork</authentication:authenticationProvider><authentication:authenticationProvider>auth.tsl.identity.card</authentication:authenticationProvider><authentication:authenticationAttribute>lt-personal-code</authentication:authenticationAttribute><authentication:authenticationAttribute>lt-company-code</authentication:authenticationAttribute><authentication:userInformation>firstName</authentication:userInformation><authentication:userInformation>lastName</authentication:userInformation><authentication:userInformation>companyName</authentication:userInformation><authentication:userInformation>email</authentication:userInformation><authentication:userInformation>address</authentication:userInformation><authentication:postbackUrl>https://localhost/</authentication:postbackUrl><authentication:customData>correlationData</authentication:customData><dsig:Signature> <dsig:SignedInfo><dsig:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/> <dsig:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/> <dsig:Reference><dsig:Transforms><dsig:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#uniqueNodeId"/></dsig:Transforms><dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><dsig:DigestValue>XidaQDNo4VKa9MDTfj+wwF2ZmfY=</dsig:DigestValue></dsig:Reference></dsig:SignedInfo><dsig:SignatureValue>fs6WHyF9oIMIhu0vvVjOo62YOeBQ3fEgBWMno36akyoDySFZuAtDgLLLmfH+ibkSDBL072/pMt8LhWhDk7fPAWu5EE+rd1wAim0Ap28MAKSlmsfvJ6H/9E3bPCDJZ27yPyBZHIpXRR6sk6YiLop7K5mxch323m9BqCsPaxZNyo712gGyyz0fNTM5jTK3Fl8mckB1SJRnB7JVUJduTBnEBRXvR9q3c6tk8VymWngYOGRDe27Uo9YEJQrnHWGGTOfDitYJR6k56uOZd4wXVwmrLdUBL0z76X/Pu20jLQsDZYx6uKcKQi9eSE15Bf6LS8jIdT9F4FsADEmu9fiNYXsWgg==</dsig:SignatureValue> <dsig:KeyInfo><dsig:X509Data/></dsig:KeyInfo></dsig:Signature></authentication:authenticationRequest>

@robrichards
Copy link
Owner

Current codebase does not support this but it looks like there is an old PR #75 which adds support. I will see about getting the support added.

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

No branches or pull requests

2 participants