Problem: sharing files via link fails with master-key enabled

Nextcloud version 11.0.1
Operating system and version CentOS 7.3.1611
Apache version 2.4.6
PHP version 7.0.15

I had a clean nextcloud install. I enabled encryption app, enabled master-key via occ and then enabled encryption.
After that, I uploaded a file to nextcloud and tried to share it via link. After I open the link on another PC, I try downloading this file and I get this:

“Can’t read file. Private key missing for user. Please try to log out and log in again.”

And here is what I see in nextcloud.log:

Exception: {“Exception”:“OCA\Encryption\Exceptions\PrivateKeyMissingException”,“Message”:“Private Key missing for user: please try to log-out and log-in again”,“Code”:0,“Trace”:"#0 /var/www/nextcloud/apps/encryption/lib/KeyManager.php(420): OCA\Encryption\Session->getPrivateKey()\n#1 /var/www/nextcloud/apps/encryption/lib/Crypto/Encryption.php(476): OCA\Encryption\KeyManager->getFileKey(’/nc17admin/file…’, ‘master_b2f4d856’)\n#2 /var/www/nextcloud/lib/private/Files/Storage/Wrapper/Encryption.php(328): OCA\Encryption\Crypto\Encryption->isReadable(’/nc17admin/file…’, NULL)\n#3 /var/www/nextcloud/lib/private/Files/Storage/Wrapper/Wrapper.php(169): OC\Files\Storage\Wrapper\Encryption->isReadable(‘files/rogue_leg…’)\n#4 /var/www/nextcloud/lib/private/Files/View.php(1120): OC\Files\Storage\Wrapper\Wrapper->isReadable(‘files/rogue_leg…’)\n#5 /var/www/nextcloud/lib/private/Files/View.php(485): OC\Files\View->basicOperation(‘isReadable’, ‘/rogue_legacy_s…’)\n#6 /var/www/nextcloud/lib/private/Files/Filesystem.php(655): OC\Files\View->isReadable(’//rogue_legacy_…’)\n#7 /var/www/nextcloud/lib/private/legacy/files.php(260): OC\Files\Filesystem::isReadable(’//rogue_legacy_…’)\n#8 /var/www/nextcloud/lib/private/legacy/files.php(120): OC_Files::getSingleFile(Object(OC\Files\View), ‘/’, ‘rogue_legacy_st…’, Array)\n#9 /var/www/nextcloud/apps/files_sharing/lib/Controllers/ShareController.php(545): OC_Files::get(’/’, ‘rogue_legacy_st…’, Array)\n#10 [internal function]: OCA\Files_Sharing\Controllers\ShareController->downloadShare(‘MEWznleDQZDF0e4’, NULL, ‘’, ‘’)\n#11 /var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php(160): call_user_func_array(Array, Array)\n#12 /var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php(90): OC\AppFramework\Http\Dispatcher->executeController(Object(OCA\Files_Sharing\Controllers\ShareController), ‘downloadShare’)\n#13 /var/www/nextcloud/lib/private/AppFramework/App.php(111): OC\AppFramework\Http\Dispatcher->dispatch(Object(OCA\Files_Sharing\Controllers\ShareController), ‘downloadShare’)\n#14 /var/www/nextcloud/lib/public/AppFramework/App.php(136): OC\AppFramework\App::main(‘ShareController’, ‘downloadShare’, Object(OC\AppFramework\DependencyInjection\DIContainer))\n#15 /var/www/nextcloud/core/routes.php(140): OCP\AppFramework\App->dispatch(‘ShareController’, ‘downloadShare’)\n#16 [internal function]: OC\Route\Router->{closure}(Array)\n#17 /var/www/nextcloud/lib/private/Route/Router.php(293): call_user_func(Object(Closure), Array)\n#18 /var/www/nextcloud/lib/base.php(983): OC\Route\Router->match(’/s/MEWznleDQZDF…’)\n#19 /var/www/nextcloud/index.php(48): OC::handleRequest()\n#20 {main}",“File”:"/var/www/nextcloud/apps/encryption/lib/Session.php",“Line”:79}

Please help. I need encryption, but I need master-key for LDAP users, many of them don’t like updating passwords everywhere…

Okay, I found the same bug in owncloud 8.2 and it was fixed here: https://github.com/owncloud/core/pull/21612
So, I hope nexcloud will fix this too in next versions…

This was well before the fork, so it should be already in the Nextcloud code. Please open a new bug report on https://github.com/nextcloud/server/issues