Skip to content

Encryption Module: moving keys will brake Nextcloud #6769

Closed

Description

Ubuntu 16.0.3 LTS X64 on ARM64 (oDroidC2)
Nextcloud 12.0.3 (plain/new installation from scratch)
PHP 7.1.10
MariaDB 10.0.31
Redis-Server 3.0.6
web-user: www-data
web-root: /var/www/nextcloud
data-dir: /var/nc_data

The encryption was configured properly on my test environement for all users:
01
02

When trying to move the keys as described in Nextclouds Admin-Documentation here the server will crash:
mkdir /etc/keys
chown -R root:www-data /etc/keys
chmod -R 0770 /etc/keys
sudo -u www-data php occ encryption:change-key-storage-root ../../../etc/keys/

grafik

grafik

No entries were generated while moving the keys. If trying to open Nextcloud the following entries are thrown:

root@ncbox:/var/www/nextcloud# cat /var/nc_data/nextcloud.log
{"reqId":"fO3t18YMOqNVYFhKJ85E","level":3,"time":"2017-10-05T08:50:05+02:00","re2.168.2.125","user":"--","app":"index","method":"GET","url":"/","message":"Exceeption":"OC\\ServiceUnavailableException","Message":"Key Storage is not e":0,"Trace":"#0 \/var\/www\/nextcloud\/apps\/encryption\/appinf28): OC\\Encryption\\Manager->isReady()\n#1 \/var\/www\/nextcloud\/e\/legacy\/app.php(209): require_once('\/var\/www\/nextcl...')\n#2 \\/nextcloud\/lib\/private\/legacy\/app.php(149): OC_App::requireAppFile)\n#3 \/var\/www\/nextcloud\/lib\/private\/legacy\/app.php(124): pp('encryption')\n#4 \/var\/www\/nextcloud\/lib\/base.php(992): OC_Aprray)\n#5 \/var\/www\/nextcloud\/index.php(48): OC::handleRequest()\n#File":"\/var\/www\/nextcloud\/lib\/private\/Encryption\/Manager.":114}","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:56.0) Gecko/fox/56.0","version":"12.0.3.3"}
root@ncbox:/var/www/nextcloud#

Running any occ the following errors appear:

An unhandled exception has been thrown:
OC\ServiceUnavailableException: Key Storage is not ready in /var/www/nextcloud/lib/private/Encryption/Manager.php:114
Stack trace:
#0 /var/www/nextcloud/apps/encryption/appinfo/app.php(28): OC\Encryption\Manager->isReady()
#1 /var/www/nextcloud/lib/private/legacy/app.php(209): require_once('/var/www/nextcl...')
#2 /var/www/nextcloud/lib/private/legacy/app.php(149): OC_App::requireAppFile('encryption')
#3 /var/www/nextcloud/lib/private/legacy/app.php(124): OC_App::loadApp('encryption')
#4 /var/www/nextcloud/lib/private/Console/Application.php(104): OC_App::loadApps()
#5 /var/www/nextcloud/console.php(99): OC\Console\Application->loadCommands(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#6 /var/www/nextcloud/occ(11): require_once('/var/www/nextcl...')

Although moving the keys was mentioned as "successfull" the keys remain in the user location instead of "/etc/keys:":

grafik

What went wrong and what would help to repair this instance?
Cheers, Carsten

Activity

  1. nickvergessen commented on Oct 5, 2017

    @nickvergessen
    Member
  2. schiessle commented on Oct 5, 2017

    @schiessle
    Member

    The folder must be somewhere in your data folder, either physically or as a mount. Otherwise Nextcloud will not be able to access it.

    I fixed the documentation: nextcloud/documentation#570

  3. nickvergessen commented on Oct 10, 2017

    @nickvergessen
    Member

    Can you check whether there is a .oc_key_storage file in that new directory?

  4. nickvergessen commented on Oct 10, 2017

    @nickvergessen
    Member

    And also make sure that the owner of the files is www-data, not root.

  5. nickvergessen commented on Oct 10, 2017

    @nickvergessen
    Member

    Can you specify the full path instead of a relative one please when moving the directory?
    I think that should fix the issue.

    Okay apparently it has to be relative, sorry

  6. nickvergessen commented on Oct 10, 2017

    @nickvergessen
    Member

    There was a wrong handling of the return, I fixed that, but now it throws an exception instead of falsely continuing: #6805

    To make your instance temporarily work again, execute the following query:

    DELETE FROM `oc_appconfig`
    WHERE `appid` = 'core'
    AND `configkey` = 'encryption_key_storage_root';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions