Commit 16b42f03 authored by Richard Mansfield's avatar Richard Mansfield

Remove duplicated code for parsing xml payload after getting new host key

Signed-off-by: default avatarRichard Mansfield <richardm@catalyst.net.nz>
parent b35d4411
......@@ -910,18 +910,8 @@ function xmldsig_envelope_strip(&$xml) {
// Does the signature match the data and the public cert?
$signature_verified = openssl_verify($payload, $signature, $peer->certificate);
if ($signature_verified == 1) {
// Parse the XML
try {
$xml = new SimpleXMLElement($payload);
return $payload;
} catch (Exception $e) {
throw new MaharaException('Signed payload is not a valid XML document', 6007);
}
}
else if ($signature_verified == 0) {
if ($signature_verified == 0) {
// Maybe the remote host is using a new key?
//$new_public_key = get_public_key($wwwroot, $peer->application->name);
// Make a dummy request so we'll be given a new key
log_info("Signature verification for message from $wwwroot failed, checking to see if they have a new signature for us");
require_once(get_config('docroot') . 'api/xmlrpc/client.php');
......@@ -932,15 +922,15 @@ function xmldsig_envelope_strip(&$xml) {
// Now use the new key and re-try verification
$peer = get_peer($wwwroot, false);
$signature_verified = openssl_verify($payload, $signature, $peer->certificate);
if ($signature_verified == 1) {
log_info("Succefully retrieved a new key for $wwwroot");
// Parse the XML
try {
$xml = new SimpleXMLElement($payload);
return $payload;
} catch (Exception $e) {
throw new MaharaException('Signed payload is not a valid XML document', 6007);
}
}
if ($signature_verified == 1) {
// Parse the XML
try {
$xml = new SimpleXMLElement($payload);
return $payload;
} catch (Exception $e) {
throw new MaharaException('Signed payload is not a valid XML document', 6007);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment