aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_encryption/lib/session.php
diff options
context:
space:
mode:
authorBjörn Schießle <schiessle@owncloud.com>2013-02-13 17:57:45 +0100
committerBjörn Schießle <schiessle@owncloud.com>2013-02-13 17:57:45 +0100
commit5005195db005fd0d7c8fdf1a73e12c4a4619acb9 (patch)
treea12a41f665ca676f720addf7e169f94691e07ebd /apps/files_encryption/lib/session.php
parent9356f9a6bf6e9bd048e31e787d5fcb621de8eebc (diff)
downloadnextcloud-server-5005195db005fd0d7c8fdf1a73e12c4a4619acb9.tar.gz
nextcloud-server-5005195db005fd0d7c8fdf1a73e12c4a4619acb9.zip
create keypair for ownCloud with empty passphrase, will be used for public link shares
Diffstat (limited to 'apps/files_encryption/lib/session.php')
-rw-r--r--apps/files_encryption/lib/session.php28
1 files changed, 28 insertions, 0 deletions
diff --git a/apps/files_encryption/lib/session.php b/apps/files_encryption/lib/session.php
index 769a40b359f..ebf7edcd715 100644
--- a/apps/files_encryption/lib/session.php
+++ b/apps/files_encryption/lib/session.php
@@ -27,6 +27,34 @@ namespace OCA\Encryption;
*/
class Session {
+
+ /**
+ * @brief if session is started, check if ownCloud key pair is set up, if not create it
+ *
+ * The ownCloud key pair is used to allow public link sharing even if encryption is enabled
+ */
+ public function __construct() {
+ $view = new \OC\Files\View('/');
+ if (!$view->is_dir('owncloud_private_key')) {
+ $view->mkdir('owncloud_private_key');
+ }
+
+ if (!$view->file_exists("/public-keys/owncloud.public.key") || !$view->file_exists("/owncloud_private_key/owncloud.private.key") ) {
+
+ $keypair = Crypt::createKeypair();
+
+ \OC_FileProxy::$enabled = false;
+ // Save public key
+ $view->file_put_contents( '/public-keys/owncloud.public.key', $keypair['publicKey'] );
+ // Encrypt private key empthy passphrase
+ $encryptedPrivateKey = Crypt::symmetricEncryptFileContent( $keypair['privateKey'], '' );
+ // Save private key
+ error_log("encrypted private key: " . $encryptedPrivateKey );
+ $view->file_put_contents( '/owncloud_private_key/owncloud.private.key', $encryptedPrivateKey );
+
+ \OC_FileProxy::$enabled = true;
+ }
+ }
/**
* @brief Sets user private key to session