From df7bfa4bf03646a4f62758c1b7745e06790ce58d Mon Sep 17 00:00:00 2001 From: ringmaster Date: Mon, 26 Aug 2013 12:08:23 -0400 Subject: [PATCH] Don't cache the pkey, skip generation if the keyfile exists --- apps/files_encryption/hooks/hooks.php | 17 +++++++++-------- apps/files_encryption/lib/helper.php | 7 ++----- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/apps/files_encryption/hooks/hooks.php b/apps/files_encryption/hooks/hooks.php index de306462d79..85169e6a1d0 100644 --- a/apps/files_encryption/hooks/hooks.php +++ b/apps/files_encryption/hooks/hooks.php @@ -36,14 +36,6 @@ class Hooks { */ public static function login($params) { $l = new \OC_L10N('files_encryption'); - //check if all requirements are met - if(!Helper::checkRequirements() || !Helper::checkConfiguration() ) { - $error_msg = $l->t("Missing requirements."); - $hint = $l->t('Please make sure that PHP 5.3.3 or newer is installed and that OpenSSL together with the PHP extension is enabled and configured properly. For now, the encryption app has been disabled.'); - \OC_App::disable('files_encryption'); - \OCP\Util::writeLog('Encryption library', $error_msg . ' ' . $hint, \OCP\Util::ERROR); - \OCP\Template::printErrorPage($error_msg, $hint); - } $view = new \OC_FilesystemView('/'); @@ -54,6 +46,15 @@ class Hooks { $util = new Util($view, $params['uid']); + //check if all requirements are met + if(!$util->ready() && (!Helper::checkRequirements() || !Helper::checkConfiguration())) { + $error_msg = $l->t("Missing requirements."); + $hint = $l->t('Please make sure that PHP 5.3.3 or newer is installed and that OpenSSL together with the PHP extension is enabled and configured properly. For now, the encryption app has been disabled.'); + \OC_App::disable('files_encryption'); + \OCP\Util::writeLog('Encryption library', $error_msg . ' ' . $hint, \OCP\Util::ERROR); + \OCP\Template::printErrorPage($error_msg, $hint); + } + // setup user, if user not ready force relogin if (Helper::setupUser($util, $params['password']) === false) { return false; diff --git a/apps/files_encryption/lib/helper.php b/apps/files_encryption/lib/helper.php index 10447a07bb8..cb5d5fdfb34 100755 --- a/apps/files_encryption/lib/helper.php +++ b/apps/files_encryption/lib/helper.php @@ -277,14 +277,11 @@ class Helper { /** * Create an openssl pkey with config-supplied settings + * WARNING: This initializes and caches a new private keypair, which is computationally expensive * @return resource The pkey resource created */ public static function getOpenSSLPkey() { - static $res = null; - if (is_null($res)) { - $res = openssl_pkey_new(self::getOpenSSLConfig()); - } - return $res; + return openssl_pkey_new(self::getOpenSSLConfig()); } /** -- 2.39.5