Skip to content
Browse files

mnet: Some very minor style (etc) fixes

Author: Donal McMullan <donal@catalyst.net.nz>
  • Loading branch information...
1 parent 840c12f commit 13c9d7e082a0af29e43796141219839714ad44b7 martinlanghoff committed
Showing with 25 additions and 17 deletions.
  1. +1 −1 admin/index.php
  2. +1 −1 admin/mnet/index.html
  3. +0 −2 admin/mnet/index.php
  4. +0 −2 admin/mnet/peers.php
  5. +23 −11 mnet/lib.php
View
2 admin/index.php
@@ -439,7 +439,7 @@
$guest->lastname = " ";
$guest->email = "root@localhost";
$guest->description = addslashes(get_string("guestuserinfo"));
- $guest->mnethostid = $CFG->mnet_localhost_id;
+ $guest->mnethostid = $CFG->mnet_localhost_id;
$guest->confirmed = 1;
$guest->lang = $CFG->lang;
$guest->timemodified= time();
View
2 admin/mnet/index.html
@@ -12,7 +12,7 @@
</tr>
<tr valign="top">
<td align="right">Public Key:</td>
- <td><pre><?php echo $keypair['certificate']; ?></pre></td>
+ <td><pre><?php echo $MNET->public_key; ?></pre></td>
</tr>
<tr valign="top">
<td align="right">Networking:</td>
View
2 admin/mnet/index.php
@@ -22,8 +22,6 @@
error('PHP Curl library is not installed');
}
- $keypair = unserialize($CFG->openssl);
-
if (!isset($CFG->mnet_dispatcher_mode)) set_config('mnet_dispatcher_mode', 'off');
/// If data submitted, process and store
View
2 admin/mnet/peers.php
@@ -35,8 +35,6 @@
$strmnetlog = get_string('mnetlog', 'mnet');
$strmnetedithost = get_string('reviewhostdetails', 'mnet');
-$keypair = unserialize($CFG->openssl);
-
if (!isset($CFG->mnet_dispatcher_mode)) set_config('mnet_dispatcher_mode', 'off');
/// If data submitted, process and store
View
34 mnet/lib.php
@@ -152,6 +152,7 @@ function mnet_sign_message($message) {
</Signature>
<object ID="XMLRPC-MSG">'.base64_encode($message).'</object>
<wwwroot>'.$MNET->wwwroot.'</wwwroot>
+ <timestamp>'.time().'</timestamp>
</signedMessage>';
return $message;
}
@@ -274,37 +275,48 @@ function mnet_generate_keypair($dn = null) {
$break = strpos($host.'/' , '/');
$host = substr($host, 0, $break);
- if ($result = get_record_select('course'," id ='1' ")) {
+ if ($result = get_record_select('course'," id ='".SITEID."' ")) {
$organization = $result->fullname;
} else {
$organization = 'None';
}
$keypair = array();
- // TODO: fix this with a redirect, form, etc.
+
+ $country = 'NZ';
+ $province = 'Wellington';
+ $locality = 'Wellington';
+ $email = $CFG->noreplyaddress;
+
+ if(!empty($USER->country)) {
+ $country = $USER->country;
+ }
+ if(!empty($USER->city)) {
+ $province = $USER->city;
+ $locality = $USER->city;
+ }
+ if(!empty($USER->email)) {
+ $email = $USER->email;
+ }
if (is_null($dn)) {
$dn = array(
- "countryName" => 'NZ',
- "stateOrProvinceName" => 'Wellington',
- "localityName" => 'Wellington',
+ "countryName" => $country,
+ "stateOrProvinceName" => $province,
+ "localityName" => $locality,
"organizationName" => $organization,
"organizationalUnitName" => 'Moodle',
"commonName" => $CFG->wwwroot,
- "emailAddress" => $CFG->noreplyaddress
+ "emailAddress" => $email
);
}
$new_key = openssl_pkey_new();
$csr_rsc = openssl_csr_new($dn, $new_key, array('private_key_bits',2048));
$selfSignedCert = openssl_csr_sign($csr_rsc, null, $new_key, 365);
-
- // You'll want to keep your certificate signing request, so we'll
- // export that to a property - csr_txt.
- openssl_csr_export($csr_rsc, $csr_txt);
unset($csr_rsc); // Free up the resource
- // We export our self-signed certificate to a string as well.
+ // We export our self-signed certificate to a string.
openssl_x509_export($selfSignedCert, $keypair['certificate']);
openssl_x509_free($selfSignedCert);

0 comments on commit 13c9d7e

Please sign in to comment.
Something went wrong with that request. Please try again.