Skip to content

Commit

Permalink
mnet: Some very minor style (etc) fixes
Browse files Browse the repository at this point in the history
Author: Donal McMullan <donal@catalyst.net.nz>
  • Loading branch information
martinlanghoff committed Jan 4, 2007
1 parent 840c12f commit 13c9d7e
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 17 deletions.
2 changes: 1 addition & 1 deletion admin/index.php
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion admin/mnet/index.html
Expand Up @@ -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>
Expand Down
2 changes: 0 additions & 2 deletions admin/mnet/index.php
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions admin/mnet/peers.php
Expand Up @@ -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
Expand Down
34 changes: 23 additions & 11 deletions mnet/lib.php
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit 13c9d7e

Please sign in to comment.