Skip to content

Commit

Permalink
New check_credentials function, and the check_common_name function ho…
Browse files Browse the repository at this point in the history
…w handles the subjectAltName type. MDL-11020, MDL-10326
  • Loading branch information
donal72 committed Oct 16, 2007
1 parent 3e2dd3f commit 00d3c66
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion mnet/peer.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,17 +141,32 @@ function delete_all_sessions() {
}

function check_common_name($key) {
$credentials = $this->check_credentials($key);
return $credentials['validTo_time_t'];
}

function check_credentials($key) {
$credentials = openssl_x509_parse($key);
if ($credentials == false) {
$this->error[] = array('code' => 3, 'text' => get_string("nonmatchingcert", 'mnet', array('','')));
return false;
} elseif (array_key_exists('subjectAltName', $credentials['subject']) && $credentials['subject']['subjectAltName'] != $this->wwwroot) {
$a[] = $credentials['subject']['subjectAltName'];
$a[] = $this->wwwroot;
$this->error[] = array('code' => 5, 'text' => get_string("nonmatchingcert", 'mnet', $a));
return false;
} elseif ($credentials['subject']['CN'] != $this->wwwroot) {
$a[] = $credentials['subject']['CN'];
$a[] = $this->wwwroot;
$this->error[] = array('code' => 4, 'text' => get_string("nonmatchingcert", 'mnet', $a));
return false;
} else {
return $credentials['validTo_time_t'];
if (array_key_exists('subjectAltName', $credentials['subject'])) {
$credentials['wwwroot'] = $credentials['subject']['subjectAltName'];
} else {
$credentials['wwwroot'] = $credentials['subject']['CN'];
}
return $credentials;
}
}

Expand Down

0 comments on commit 00d3c66

Please sign in to comment.