]> source.dussan.org Git - nextcloud-server.git/commitdiff
Don't cache the pkey, skip generation if the keyfile exists
authorringmaster <epithet@gmail.com>
Mon, 26 Aug 2013 16:08:23 +0000 (12:08 -0400)
committerringmaster <epithet@gmail.com>
Mon, 2 Sep 2013 13:59:00 +0000 (09:59 -0400)
apps/files_encryption/hooks/hooks.php
apps/files_encryption/lib/helper.php

index de306462d79062a7fcd7ba876a9e8e624936dc06..85169e6a1d099d46389de25fd771c40dcabfc209 100644 (file)
@@ -36,14 +36,6 @@ class Hooks {
         */\r
        public static function login($params) {\r
                $l = new \OC_L10N('files_encryption');\r
-               //check if all requirements are met\r
-               if(!Helper::checkRequirements() || !Helper::checkConfiguration() ) {\r
-                       $error_msg = $l->t("Missing requirements.");\r
-                       $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.');\r
-                       \OC_App::disable('files_encryption');\r
-                       \OCP\Util::writeLog('Encryption library', $error_msg . ' ' . $hint, \OCP\Util::ERROR);\r
-                       \OCP\Template::printErrorPage($error_msg, $hint);\r
-               }\r
 \r
                $view = new \OC_FilesystemView('/');\r
 \r
@@ -54,6 +46,15 @@ class Hooks {
 \r
                $util = new Util($view, $params['uid']);\r
 \r
+               //check if all requirements are met\r
+               if(!$util->ready() && (!Helper::checkRequirements() || !Helper::checkConfiguration())) {\r
+                       $error_msg = $l->t("Missing requirements.");\r
+                       $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.');\r
+                       \OC_App::disable('files_encryption');\r
+                       \OCP\Util::writeLog('Encryption library', $error_msg . ' ' . $hint, \OCP\Util::ERROR);\r
+                       \OCP\Template::printErrorPage($error_msg, $hint);\r
+               }\r
+\r
                // setup user, if user not ready force relogin\r
                if (Helper::setupUser($util, $params['password']) === false) {\r
                        return false;\r
index 10447a07bb81f34aeb164f21ab292f3bbda2be99..cb5d5fdfb34fbbc43850720ae53333065cd6f933 100755 (executable)
@@ -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());
        }
 
        /**