Skip to content

Commit

Permalink
Merge branch 'MDL-75645_311' of https://github.com/stronk7/moodle int…
Browse files Browse the repository at this point in the history
…o MOODLE_311_STABLE
  • Loading branch information
junpataleta committed Oct 19, 2022
2 parents a778af1 + 1ff0799 commit fcfd012
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 12 deletions.
13 changes: 3 additions & 10 deletions mnet/environment.php
Expand Up @@ -73,10 +73,7 @@ function get_keypair() {
list($this->keypair['certificate'], $this->keypair['keypair_PEM']) = explode('@@@@@@@@', $keypair);
}

if ($this->public_key_expires > time()) {
$this->keypair['privatekey'] = openssl_pkey_get_private($this->keypair['keypair_PEM']);
$this->keypair['publickey'] = openssl_pkey_get_public($this->keypair['certificate']);
} else {
if ($this->public_key_expires <= time()) {
// Key generation/rotation

// 1. Archive the current key (if there is one).
Expand Down Expand Up @@ -150,15 +147,11 @@ function replace_keys() {

function get_private_key() {
if (empty($this->keypair)) $this->get_keypair();
if (isset($this->keypair['privatekey'])) return $this->keypair['privatekey'];
$this->keypair['privatekey'] = openssl_pkey_get_private($this->keypair['keypair_PEM']);
return $this->keypair['privatekey'];
return openssl_pkey_get_private($this->keypair['keypair_PEM']);
}

function get_public_key() {
if (!isset($this->keypair)) $this->get_keypair();
if (isset($this->keypair['publickey'])) return $this->keypair['publickey'];
$this->keypair['publickey'] = openssl_pkey_get_public($this->keypair['certificate']);
return $this->keypair['publickey'];
return openssl_pkey_get_public($this->keypair['certificate']);
}
}
2 changes: 0 additions & 2 deletions mnet/lib.php
Expand Up @@ -318,8 +318,6 @@ function mnet_get_keypair() {
if (!is_null($keypair)) return $keypair;
if ($result = get_config('mnet', 'openssl')) {
list($keypair['certificate'], $keypair['keypair_PEM']) = explode('@@@@@@@@', $result);
$keypair['privatekey'] = openssl_pkey_get_private($keypair['keypair_PEM']);
$keypair['publickey'] = openssl_pkey_get_public($keypair['certificate']);
return $keypair;
} else {
$keypair = mnet_generate_keypair();
Expand Down

0 comments on commit fcfd012

Please sign in to comment.