Skip to content

Commit

Permalink
MDL-16286 MDL-16285 Bring 'signed by old key' logic together
Browse files Browse the repository at this point in the history
and add appropriate comments


Author: Peter Bulmer <peter.bulmer@catalyst.net.nz>
  • Loading branch information
peterbulmer committed Sep 7, 2008
1 parent 2a75520 commit c7c5561
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions mnet/xmlrpc/server.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,21 @@ function mnet_server_strip_wrappers($HTTP_RAW_POST_DATA) {
$isOpen = openssl_open(base64_decode($data), $payload, base64_decode($key), $keyresource);
if ($isOpen) {
// It's an older code, sir, but it checks out
$push_current_key = true;
break;

// The peer used one of our public keys that have expired, we will return a
// signed/encrypted error message containing our new public key
// Sign message with our old key, and encrypt to the peer's private key.

// Fabricate 'was_signed'
// Set here so that we sign the response containing the new public key.
$MNET_REMOTE_CLIENT->was_signed();

// 'Was_encrypted' is mostly true
// Set here so that the response is encrypted to the remote peer's private key.
$MNET_REMOTE_CLIENT->was_encrypted();

// nb 'srvr_fault_xml' used to avoid use of get_string on our new public_key
exit(mnet_server_fault_xml(7025, $MNET->public_key, $keyresource));
}
}
}
Expand All @@ -190,14 +203,6 @@ function mnet_server_strip_wrappers($HTTP_RAW_POST_DATA) {

unset($payload);

// if the peer used one of our public keys that have expired, we will
// return a signed/encrypted error message with our new public key
if($push_current_key) {
// NOTE: Here, we use the 'mnet_server_fault_xml' to avoid
// get_string being called on our public_key
exit(mnet_server_fault_xml(7025, $MNET->public_key, $keyresource));
}

/**
* Get the certificate (i.e. public key) from the remote server.
*/
Expand Down

0 comments on commit c7c5561

Please sign in to comment.