Skip to content

Commit

Permalink
mnet: try to stop trailing slashes in urls from getting through, bett…
Browse files Browse the repository at this point in the history
…er error msg if we dont like the SSL cert
  • Loading branch information
martinlanghoff committed Jan 18, 2007
1 parent 8d13ed1 commit a4d967a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
10 changes: 9 additions & 1 deletion admin/mnet/peers.php
Expand Up @@ -47,6 +47,10 @@
/// If data submitted, process and store /// If data submitted, process and store
if (($form = data_submitted()) && confirm_sesskey()) { if (($form = data_submitted()) && confirm_sesskey()) {


if (!empty($form->wwwroot)) {
// ensure we remove trailing slashes
$form->wwwroot = preg_replace(':/$:', '', $form->wwwroot);
}
if (!empty($form->updateregisterall)) { if (!empty($form->updateregisterall)) {
if (!empty($form->registerallhosts)) { if (!empty($form->registerallhosts)) {
set_config('mnet_register_allhosts',1); set_config('mnet_register_allhosts',1);
Expand Down Expand Up @@ -93,7 +97,11 @@
$mnet_peer->public_key_expires = $mnet_peer->check_common_name($form->public_key); $mnet_peer->public_key_expires = $mnet_peer->check_common_name($form->public_key);
if ($mnet_peer->public_key_expires == false) { if ($mnet_peer->public_key_expires == false) {
$mnet_peer->public_key == $oldkey; $mnet_peer->public_key == $oldkey;
error(get_string("invalidpubkey", 'mnet'),'peers.php?step=update&amp;hostid='.$mnet_peer->id); $errmsg = '<br />';
foreach ($mnet_peer->error as $err) {
$errmsg .= $err['code'] . ': ' . $err['text'].'<br />';
}
error(get_string("invalidpubkey", 'mnet') . $errmsg ,'peers.php?step=update&amp;hostid='.$mnet_peer->id);
exit; exit;
} }
} }
Expand Down
3 changes: 3 additions & 0 deletions mnet/lib.php
Expand Up @@ -309,6 +309,9 @@ function mnet_generate_keypair($dn = null, $days=28) {
); );
} }


// ensure we remove trailing slashes
$dn["commonName"] = preg_replace(':/$:', '', $dn["commonName"]);

$new_key = openssl_pkey_new(); $new_key = openssl_pkey_new();
$csr_rsc = openssl_csr_new($dn, $new_key, array('private_key_bits',2048)); $csr_rsc = openssl_csr_new($dn, $new_key, array('private_key_bits',2048));
$selfSignedCert = openssl_csr_sign($csr_rsc, null, $new_key, $days); $selfSignedCert = openssl_csr_sign($csr_rsc, null, $new_key, $days);
Expand Down

0 comments on commit a4d967a

Please sign in to comment.