Server side encryption and Amazon S3 buckets not working

Support intro

Sorry to hear you’re facing problems :slightly_frowning_face:

help.nextcloud.com is for home users. If you’re running a business, get help on portal.nextcloud.com so we can make sure your business keeps running smoothly.

In order to help you as quickly as possible, before clicking Create Topic please provide as much of the below as you can. Feel free to use a pastebin service for logs, otherwise either indent short log examples with four spaces:

example

Or for longer, use three backticks above and below the code snippet:

longer
example
here

Remember, the below information may be requested if it isn’t supplied; for fastest response please provide as much as you can :heart:

Please delete everything above when creating your topic and provide the following:

Nextcloud version (eg, 12.0.2): 13.01 or 12.06
Operating system and version (eg, Ubuntu 17.04): Raspbian stretch as well as Ubuntu 16.04
Apache or nginx version (eg, Apache 2.4.25): Apache/2.4.25
PHP version (eg, 7.1): 7.0.27

The issue you are facing:

Encrypted files stored in Amazon S3 bucket (mounted as external storage) cannot be downloaded/decrypted.

Steps to replicate it:

  1. Install a new instance of nextcloud 13.01 or 12.06
  2. Enable “default encryption” and “external storage” apps
  3. Connect Amazon S3 storage as external drive (After log out and log back in).
  4. Upload is successful but download fails.
  5. If I disable encryption everything works as expected.

The output of your Nextcloud log in Admin > Logging:

Error	PHP	Uncaught Error: Access to undeclared static property: OC\Files\Filesystem::$normalizedPathCache in /home/pi/website/nextcloud/lib/private/Files/Filesystem.php:796 Stack trace: #0 /home/pi/website/nextcloud/lib/private/Files/View.php(2057): OC\Files\Filesystem::normalizePath('/aparanjape/fil...') #1 /home/pi/website/nextcloud/lib/private/Files/View.php(1182): OC\Files\View->unlockFile('/AWS Storage/CM...', 1) #2 [internal function]: OC\Files\View->OC\Files\{closure}() #3 /home/pi/website/nextcloud/apps/files_external/3rdparty/icewind/streams/src/CallbackWrapper.php(109): call_user_func(Object(Closure)) #4 [internal function]: Icewind\Streams\CallbackWrapper->stream_close() #5 {main} thrown at /home/pi/website/nextcloud/lib/private/Files/Filesystem.php#796	2018-03-24T12:11:31-0700
Error	no app in context	OC\Encryption\Exceptions\DecryptionFailedException: Encryption library: Decryption (symmetric) of content failed:
/home/pi/website/nextcloud/apps/encryption/lib/Crypto/Crypt.php - line 471: OCA\Encryption\Crypto\Crypt->decrypt(*** sensitive parameters replaced ***)
/home/pi/website/nextcloud/apps/encryption/lib/Crypto/Encryption.php - line 380: OCA\Encryption\Crypto\Crypt->symmetricDecryptFileContent('ZbZQtv4impawB7Y...', '\xC7\x034\xF9\xDE\xF72*\xF9\xBC\xB8\xD1\xA6\x9Bu...', 'AES-256-CTR', 1, 0)
/home/pi/website/nextcloud/lib/private/Files/Stream/Encryption.php - line 464: OCA\Encryption\Crypto\Encryption->decrypt(*** sensitive parameters replaced ***)
/home/pi/website/nextcloud/lib/private/Files/Stream/Encryption.php - line 295: OC\Files\Stream\Encryption->readCache()
[internal function] OC\Files\Stream\Encryption->stream_read(8192)
/home/pi/website/nextcloud/apps/files_external/3rdparty/icewind/streams/src/Wrapper.php - line 83: fread(Resource id #71, 8192)
/home/pi/website/nextcloud/apps/files_external/3rdparty/icewind/streams/src/CallbackWrapper.php - line 91: Icewind\Streams\Wrapper->stream_read(8192)
[internal function] Icewind\Streams\CallbackWrapper->stream_read(8192)
/home/pi/website/nextcloud/lib/private/Files/View.php - line 425: fread(Resource id #74, 8192)
/home/pi/website/nextcloud/lib/private/legacy/files.php - line 310: OC\Files\View->readfile('/AWS Storage/CM...')
/home/pi/website/nextcloud/lib/private/legacy/files.php - line 122: OC_Files getSingleFile(Object(OC\Files\View), '/AWS Storage', 'CMA_53000_03162...', Array)
/home/pi/website/nextcloud/apps/files/ajax/download.php - line 64: OC_Files get('/AWS Storage', 'CMA_53000_03162...', Array)
/home/pi/website/nextcloud/lib/private/Route/Route.php - line 155: require_once('/home/pi/websit...')
[internal function] OC\Route\Route->OC\Route\{closure}(*** sensitive parameters replaced ***)
/home/pi/website/nextcloud/lib/private/Route/Router.php - line 297: call_user_func(Object(Closure), Array)
/home/pi/website/nextcloud/lib/base.php - line 998: OC\Route\Router->match('/apps/files/aja...')
/home/pi/website/nextcloud/index.php - line 37: OC handleRequest()
{main}
2018-03-24T12:11:27-0700

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

<?php
$CONFIG = array (
  'instanceid' => 'ocx2vv7alr00',
  'passwordsalt' => xxxx',
  'secret' => 'xxxxxx',
  'trusted_domains' =>
  array (
    0 => 'xxxxx',
  ),
  'datadirectory' => '/home/pi/serverHome',
  'overwrite.cli.url' => 'xxxxx',
  'dbtype' => 'mysql',
  'version' => '13.0.1.1',
  'dbname' => 'serverDB',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'dbuser' => 'nextcloud_db_user',
  'dbpassword' => 'xxxx',
  'installed' => true,
  'loglevel' => 0,
  'maintenance' => false,
  'memcache.local' => '\\OC\\Memcache\\Redis',
  'filelockin.enabled' => true,
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'redis' =>
  array (
    'host' => 'localhost',
    'port' => 6379,
  ),
);

The output of your Apache/nginx/system log in /var/log/____:

[Sun Mar 25 08:52:15.318741 2018] [core:notice] [pid 32624] AH00094: Command line: '/usr/sbin/apache2'
[Sun Mar 25 09:10:10.919565 2018] [:error] [pid 32628] [client xxxx] PHP Fatal error:  Uncaught Error: Access to undeclared static property: OC\\Files\\Filesystem::$normalizedPathCache in /home/pi/website/nextcloud_13_01/lib/private/Files/Filesystem.php:804\nStack trace:\n#0 /home/pi/website/nextcloud_13_01/lib/private/Files/View.php(2062): OC\\Files\\Filesystem::normalizePath('/aparanjape/fil...')\n#1 /home/pi/website/nextcloud_13_01/lib/private/Files/View.php(1193): OC\\Files\\View->unlockFile('/AmazonS3/CMA_5...', 1)\n#2 [internal function]: OC\\Files\\View->OC\\Files\\{closure}()\n#3 /home/pi/website/nextcloud_13_01/apps/files_external/3rdparty/icewind/streams/src/CallbackWrapper.php(109): call_user_func(Object(Closure))\n#4 [internal function]: Icewind\\Streams\\CallbackWrapper->stream_close()\n#5 {main}\n  thrown in /home/pi/website/nextcloud_13_01/lib/private/Files/Filesystem.php on line 804
[Sun Mar 25 09:11:11.225989 2018] [:error] [pid 2199] [client xxxx] PHP Fatal error:  Uncaught Error: Access to undeclared static property: OC\\Files\\Filesystem::$normalizedPathCache in /home/pi/website/nextcloud_13_01/lib/private/Files/Filesystem.php:804\nStack trace:\n#0 /home/pi/website/nextcloud_13_01/lib/private/Files/View.php(2062): OC\\Files\\Filesystem::normalizePath('/aparanjape/fil...')\n#1 /home/pi/website/nextcloud_13_01/lib/private/Files/View.php(1193): OC\\Files\\View->unlockFile('/AmazonS3/CMA_5...', 1)\n#2 [internal function]: OC\\Files\\View->OC\\Files\\{closure}()\n#3 /home/pi/website/nextcloud_13_01/apps/files_external/3rdparty/icewind/streams/src/CallbackWrapper.php(109): call_user_func(Object(Closure))\n#4 [internal function]: Icewind\\Streams\\CallbackWrapper->stream_close()\n#5 {main}\n  thrown in /home/pi/website/nextcloud_13_01/lib/private/Files/Filesystem.php on line 804