diff --git a/mnet/environment.php b/mnet/environment.php index 236e4b65ef7..fccedb7b975 100644 --- a/mnet/environment.php +++ b/mnet/environment.php @@ -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). @@ -150,15 +147,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']); } } diff --git a/mnet/lib.php b/mnet/lib.php index 3937b4491f3..96552b2224a 100644 --- a/mnet/lib.php +++ b/mnet/lib.php @@ -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();