Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge branch 'wip-MDL-25299-m22' of git://github.com/samhemelryk/mood…

…le into MOODLE_22_STABLE
  • Loading branch information...
commit f24d063a5e916cedcf9be9683cf27d90e2682d81 2 parents ab04c70 + 5ac02b6
Eloy Lafuente (stronk7) authored February 20, 2012
5  admin/mnet/peer_forms.php
@@ -98,6 +98,7 @@ function definition() {
98 98
 
99 99
         $mform->addElement('textarea', 'public_key', get_string('publickey', 'mnet'), array('rows' => 17, 'cols' => 100, 'class' => 'smalltext'));
100 100
         $mform->setType('public_key', PARAM_PEM);
  101
+        $mform->addRule('public_key', get_string('required'), 'required');
101 102
 
102 103
         // finished with form controls, now the static informational stuff
103 104
         if ($mnet_peer && !empty($mnet_peer->bootstrapped)) {
@@ -160,7 +161,9 @@ function validation($data) {
160 161
         }
161 162
         $mnet_peer = new mnet_peer(); // idiotic api
162 163
         $mnet_peer->wwwroot = $data['wwwroot']; // just hard-set this rather than bootstrap the object
163  
-        if (!$credentials = $mnet_peer->check_credentials($data['public_key'])) {
  164
+        if (empty($data['public_key'])) {
  165
+            $errors['public_key'] = get_string('publickeyrequired', 'mnet');
  166
+        } else if (!$credentials = $mnet_peer->check_credentials($data['public_key'])) {
164 167
             $errmsg = '';
165 168
             foreach ($mnet_peer->error as $err) {
166 169
                 $errmsg .= $err['code'] . ': ' . $err['text'].'<br />';
1  lang/en/mnet.php
@@ -179,6 +179,7 @@
179 179
 $string['promiscuous'] = 'Promiscuous';
180 180
 $string['publickey'] = 'Public key';
181 181
 $string['publickey_help'] = 'The public key is automatically obtained from the remote server.';
  182
+$string['publickeyrequired'] = 'You must provide a public key.';
182 183
 $string['publish'] = 'Publish';
183 184
 $string['reallydeleteserver'] = 'Are you sure you want to delete the server';
184 185
 $string['receivedwarnings'] = 'The following warnings were received';
2  mnet/peer.php
@@ -155,7 +155,7 @@ function check_common_name($key) {
155 155
     function check_credentials($key) {
156 156
         $credentials = openssl_x509_parse($key);
157 157
         if ($credentials == false) {
158  
-            $this->error[] = array('code' => 3, 'text' => get_string("nonmatchingcert", 'mnet', array('','')));
  158
+            $this->error[] = array('code' => 3, 'text' => get_string("nonmatchingcert", 'mnet', array('subject' => '','host' => '')));
159 159
             return false;
160 160
         } elseif (array_key_exists('subjectAltName', $credentials['subject']) && $credentials['subject']['subjectAltName'] != $this->wwwroot) {
161 161
             $a['subject'] = $credentials['subject']['subjectAltName'];

0 notes on commit f24d063

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