Hello everyone
Recently me and a friend of mine, who knows about about programming a lot, decided to setup a Nextcloud for me. Everything was working perfectly fine for me until I saw “encryption” settings in my nextcloud app for Windows. Without much thinking I enabled it and that’s where the problems started happening. I couldn’t sync and download the files. I would always get Internal Server Error when trying to open files on Nextcloud website itself. This is a snippet from my log files:
[webdav] Error: Sabre\DAV\Exception\ServiceUnavailable: Encryption not ready: Default encryption module not loaded at <<closure>>
0. /srv/nextcloud/apps/dav/lib/Connector/Sabre/File.php line 318
OCA\DAV\Connector\Sabre\File->convertToSabreException()
1. /srv/nextcloud/apps/dav/lib/Connector/Sabre/Directory.php line 149
OCA\DAV\Connector\Sabre\File->put()
2. /srv/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php line 1098
OCA\DAV\Connector\Sabre\Directory->createFile("*** sensitive parameters replaced ***")
3. /srv/nextcloud/3rdparty/sabre/dav/lib/DAV/CorePlugin.php line 504
Sabre\DAV\Server->createFile("*** sensitive parameters replaced ***")
4. /srv/nextcloud/3rdparty/sabre/event/lib/WildcardEmitterTrait.php line 89
Sabre\DAV\CorePlugin->httpPut()
5. /srv/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php line 472
Sabre\DAV\Server->emit()
6. /srv/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php line 253
Sabre\DAV\Server->invokeMethod()
7. /srv/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php line 321
Sabre\DAV\Server->start()
8. /srv/nextcloud/apps/dav/lib/Server.php line 365
Sabre\DAV\Server->exec()
9. /srv/nextcloud/apps/dav/appinfo/v2/remote.php line 35
OCA\DAV\Server->exec()
10. /srv/nextcloud/remote.php line 172
require_once("/srv/nextcloud/ ... p")
Caused by:
OC\Encryption\Exceptions\ModuleDoesNotExistsException: Default encryption module not loaded at <<closure>>
0. /srv/nextcloud/lib/private/Encryption/Manager.php line 171
OC\Encryption\Manager->getDefaultEncryptionModule()
1. /srv/nextcloud/lib/private/Files/Storage/Wrapper/Encryption.php line 1081
OC\Encryption\Manager->getEncryptionModule()
2. /srv/nextcloud/lib/private/Files/Storage/Wrapper/Encryption.php line 470
OC\Files\Storage\Wrapper\Encryption->shouldEncrypt()
3. /srv/nextcloud/lib/private/Files/Storage/Wrapper/Encryption.php line 1089
OC\Files\Storage\Wrapper\Encryption->fopen()
4. /srv/nextcloud/lib/private/Files/Storage/Wrapper/Wrapper.php line 644
OC\Files\Storage\Wrapper\Encryption->writeStream()
5. /srv/nextcloud/apps/files_accesscontrol/lib/StorageWrapper.php line 321
OC\Files\Storage\Wrapper\Wrapper->writeStream()
6. /srv/nextcloud/apps/dav/lib/Connector/Sabre/File.php line 248
OCA\FilesAccessControl\StorageWrapper->writeStream()
7. /srv/nextcloud/apps/dav/lib/Connector/Sabre/Directory.php line 149
OCA\DAV\Connector\Sabre\File->put()
8. /srv/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php line 1098
OCA\DAV\Connector\Sabre\Directory->createFile("*** sensitive parameters replaced ***")
9. /srv/nextcloud/3rdparty/sabre/dav/lib/DAV/CorePlugin.php line 504
Sabre\DAV\Server->createFile("*** sensitive parameters replaced ***")
10. /srv/nextcloud/3rdparty/sabre/event/lib/WildcardEmitterTrait.php line 89
Sabre\DAV\CorePlugin->httpPut()
11. /srv/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php line 472
Sabre\DAV\Server->emit()
12. /srv/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php line 253
Sabre\DAV\Server->invokeMethod()
13. /srv/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php line 321
Sabre\DAV\Server->start()
14. /srv/nextcloud/apps/dav/lib/Server.php line 365
Sabre\DAV\Server->exec()
15. /srv/nextcloud/apps/dav/appinfo/v2/remote.php line 35
OCA\DAV\Server->exec()
16. /srv/nextcloud/remote.php line 172
require_once("/srv/nextcloud/ ... p")
PUT /remote.php/dav/files/admin/Phone%20backup/2023/10/11/Screenshots/Screenshot_20231011_112003_Signal.jpg
from 45.87.35.128 by admin at 2023-10-12T05:03:13+00:00
PHP snippet (I hope this is what you’re looking for):
require_once __DIR__ . '/lib/versioncheck.php';
try {
require_once __DIR__ . '/lib/base.php';
OC::handleRequest();
} catch (\OC\ServiceUnavailableException $ex) {
\OC::$server->getLogger()->logException($ex, ['app' => 'index']);
//show the user a detailed error page
OC_Template::printExceptionErrorPage($ex, 503);
} catch (\OCP\HintException $ex) {
try {
OC_Template::printErrorPage($ex->getMessage(), $ex->getHint(), 503);
} catch (Exception $ex2) {
try {
\OC::$server->getLogger()->logException($ex, ['app' => 'index']);
\OC::$server->getLogger()->logException($ex2, ['app' => 'index']);
} catch (Throwable $e) {
// no way to log it properly - but to avoid a white page of death we try harder and ignore this one here
}
//show the user a detailed error page
OC_Template::printExceptionErrorPage($ex, 500);
}
} catch (\OC\User\LoginException $ex) {
$request = \OC::$server->getRequest();
/**
* Routes with the @CORS annotation and other API endpoints should
* not return a webpage, so we only print the error page when html is accepted,
* otherwise we reply with a JSON array like the SecurityMiddleware would do.
*/
if (stripos($request->getHeader('Accept'), 'html') === false) {
http_response_code(401);
header('Content-Type: application/json; charset=utf-8');
echo json_encode(['message' => $ex->getMessage()]);
exit();
}
OC_Template::printErrorPage($ex->getMessage(), $ex->getMessage(), 401);
} catch (Exception $ex) {
\OC::$server->getLogger()->logException($ex, ['app' => 'index']);
//show the user a detailed error page
OC_Template::printExceptionErrorPage($ex, 500);
} catch (Error $ex) {
try {
\OC::$server->getLogger()->logException($ex, ['app' => 'index']);
} catch (Error $e) {
http_response_code(500);
header('Content-Type: text/plain; charset=utf-8');
print("Internal Server Error\n\n");
print("The server encountered an internal error and was unable to complete your request.\n");
print("Please contact the server administrator if this error reappears multiple times, please include the technical details below in your report.\n");
print("More details can be found in the webserver log.\n");
throw $ex;
}
OC_Template::printExceptionErrorPage($ex, 500);
}
Nextcloud version: 27.1.2
Operating system and version: Ubuntu 22.04
Apache or nginx version: No idea
PHP version:
$OC_Version = array(27,1,2,1);
$OC_VersionString = '27.1.2';
$OC_Edition = '';
$OC_Channel = 'stable';
$OC_VersionCanBeUpgradedFrom = array (
'nextcloud' =>
array (
'26.0' => true,
'27.0' => true,
'27.1' => true,
),
'owncloud' =>
array (
'10.11' => true,
),
);
$OC_Build = '2023-10-05T10:53:45+00:00 11b2762d3cb72af264d03dcb201eabf0463dff0b';
$vendor = 'nextcloud';
This is the first time I’m seen this error
Steps to replicate it:
- Setup Nextcloud
- Enable encryption
- Few hours later disable it like a fool and boom - you got a broken cloud
Do mind that I’m not an expert in this