diff options
author | Björn Schießle <bjoern@schiessle.org> | 2013-08-07 23:35:53 -0700 |
---|---|---|
committer | Björn Schießle <bjoern@schiessle.org> | 2013-08-07 23:35:53 -0700 |
commit | cc03251c8f7215de515bf57d4dcba0ffe20af617 (patch) | |
tree | f9ec1381e4b89d1ed2fb06f627144527ab149f92 | |
parent | 248e7a06927e8521cb7f76a7489cabb271e93049 (diff) | |
parent | af219650acf8a451186d6e504fd0483ad02db4f9 (diff) | |
download | nextcloud-server-cc03251c8f7215de515bf57d4dcba0ffe20af617.tar.gz nextcloud-server-cc03251c8f7215de515bf57d4dcba0ffe20af617.zip |
Merge pull request #4268 from owncloud/encryption_check_config
Encryption app, check config
-rw-r--r-- | apps/files_encryption/hooks/hooks.php | 4 | ||||
-rwxr-xr-x | apps/files_encryption/lib/crypt.php | 4 | ||||
-rwxr-xr-x | apps/files_encryption/lib/helper.php | 15 |
3 files changed, 20 insertions, 3 deletions
diff --git a/apps/files_encryption/hooks/hooks.php b/apps/files_encryption/hooks/hooks.php index 741df166b70..07da839e8a2 100644 --- a/apps/files_encryption/hooks/hooks.php +++ b/apps/files_encryption/hooks/hooks.php @@ -40,9 +40,9 @@ class Hooks { public static function login($params) {
$l = new \OC_L10N('files_encryption');
//check if all requirements are met
- if(!Helper::checkRequirements() ) {
+ 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 the OpenSSL PHP extension is enabled and configured properly. For now, the encryption app has been disabled.');
+ $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);
diff --git a/apps/files_encryption/lib/crypt.php b/apps/files_encryption/lib/crypt.php index 6543a0de5f3..c3e88e5944e 100755 --- a/apps/files_encryption/lib/crypt.php +++ b/apps/files_encryption/lib/crypt.php @@ -57,7 +57,9 @@ class Crypt { if ($res === false) {
\OCP\Util::writeLog('Encryption library', 'couldn\'t generate users key-pair for ' . \OCP\User::getUser(), \OCP\Util::ERROR);
- \OCP\Util::writeLog('Encryption library', openssl_error_string(), \OCP\Util::ERROR);
+ while ($msg = openssl_error_string()) {
+ \OCP\Util::writeLog('Encryption library', 'openssl_pkey_new() fails: ' . $msg, \OCP\Util::ERROR);
+ }
} elseif (openssl_pkey_export($res, $privateKey)) {
// Get public key
$keyDetails = openssl_pkey_get_details($res);
diff --git a/apps/files_encryption/lib/helper.php b/apps/files_encryption/lib/helper.php index 6eee8fed6a6..b09c584c0b8 100755 --- a/apps/files_encryption/lib/helper.php +++ b/apps/files_encryption/lib/helper.php @@ -232,6 +232,21 @@ class Helper { return (bool) $result; } + + /** + * check some common errors if the server isn't configured properly for encryption + * @return bool true if configuration seems to be OK + */ + public static function checkConfiguration() { + if(openssl_pkey_new(array('private_key_bits' => 4096))) { + return true; + } else { + while ($msg = openssl_error_string()) { + \OCP\Util::writeLog('Encryption library', 'openssl_pkey_new() fails: ' . $msg, \OCP\Util::ERROR); + } + return false; + } + } /** * @brief glob uses different pattern than regular expressions, escape glob pattern only |