Merge branch 'MDL-75645_400' of https://github.com/stronk7/moodle into MOODLE_400_STABLE

This commit is contained in:
Jun Pataleta
2022-10-19 15:37:26 +08:00
2 changed files with 3 additions and 12 deletions
+3 -10
View File
@@ -73,10 +73,7 @@ class mnet_environment {
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).
@@ -153,15 +150,11 @@ class mnet_environment {
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
View File
@@ -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();