integration_google icon indicating copy to clipboard operation
integration_google copied to clipboard

OCP\Encryption\Exceptions\GenericEncryptionException: Bad Signature

Open Niveshkrishna opened this issue 3 years ago • 8 comments

I have SSE enabled for NC version : 20.0.11, Integration Google App version : 1.0.2

I get the following error when I try to open/download files synced from google drive and google photos.

[webdav] Fatal: OCP\Encryption\Exceptions\GenericEncryptionException: Bad Signature at <<closure>>

 0. /var/www/html/apps/encryption/lib/Crypto/Crypt.php line 479
    OCA\Encryption\Crypto\Crypt->checkSignature("*** sensitive parameters replaced ***")
 1. /var/www/html/apps/encryption/lib/Crypto/Encryption.php line 376
    OCA\Encryption\Crypto\Crypt->symmetricDecryptFileContent("*** sensitive parameter replaced ***", null, "AES-256-CTR", 1, "*** sensitive parameter replaced ***")
 2. /var/www/html/lib/private/Files/Stream/Encryption.php line 501
    OCA\Encryption\Crypto\Encryption->decrypt("*** sensitive parameters replaced ***")
 3. /var/www/html/lib/private/Files/Stream/Encryption.php line 299
    OC\Files\Stream\Encryption->readCache()
 4. <<closure>>
    OC\Files\Stream\Encryption->stream_read(8192)
 5. /var/www/html/3rdparty/icewind/streams/src/Wrapper.php line 91
    fread(null, 8192)
 6. /var/www/html/3rdparty/icewind/streams/src/CallbackWrapper.php line 98
    Icewind\Streams\Wrapper->stream_read(8192)
 7. <<closure>>
    Icewind\Streams\CallbackWrapper->stream_read(8192)
 8. /var/www/html/3rdparty/sabre/http/lib/Sapi.php line 112
    stream_copy_to_stream(null, null, 4194304)
 9. /var/www/html/3rdparty/sabre/dav/lib/DAV/Server.php line 492
    Sabre\HTTP\Sapi::sendResponse(Sabre\HTTP\Response {})
10. /var/www/html/3rdparty/sabre/dav/lib/DAV/Server.php line 251
    Sabre\DAV\Server->invokeMethod(Sabre\HTTP\Request {}, Sabre\HTTP\Response {})
11. /var/www/html/3rdparty/sabre/dav/lib/DAV/Server.php line 319
    Sabre\DAV\Server->start()
12. /var/www/html/apps/dav/lib/Server.php line 332
    Sabre\DAV\Server->exec()
13. /var/www/html/apps/dav/appinfo/v2/remote.php line 35
    OCA\DAV\Server->exec()
14. /var/www/html/remote.php line 167
    require_once("/var/www/html/a ... p")

GET /remote.php/dav/files{HIDDEN}/Google%20Drive/Nextcloud%20Manual.pdf
from {HIDDEN}

Any idea what could be wrong here? Is the integration app compatible with SSE?

Thanks

Niveshkrishna avatar Aug 05 '21 07:08 Niveshkrishna

Similar problem reported by this user. My intuition is that it's not compatible. Any feedback, @eneiluj @nickvergessen ?

arnauvp avatar Aug 09 '21 10:08 arnauvp

Im not affiliated with the app nor available at the moment

nickvergessen avatar Aug 09 '21 11:08 nickvergessen

Sorry, I maybe should have mentioned @PVince81 and @rakekniven who seem to have merged PRs recently.

arnauvp avatar Aug 10 '21 10:08 arnauvp

@Niveshkrishna Was SSE enabled when you imported the files from google? Even if it wasn't, I don't think this is related.

Maybe the problem is that files are written chunk by chunk by the Http client which might ignore SSE. I'll make some tests and keep you informed.

julien-nc avatar Aug 27 '21 12:08 julien-nc

@eneiluj Yes, SSE was enabled on this NC instance.

Calendar and contacts importing works fine. So maybe you are right about how data is copied and written chunk by chunk.

Niveshkrishna avatar Aug 27 '21 14:08 Niveshkrishna

It's now solved. You can try v1.0.5-1-nightly which is only compatible with Nextcloud >= 22.

I changed the way files are written. Instead of giving a file resource to the Http client (via the 'sink' parameter), we now get a stream response ('stream' param) and manually read it to write the file chunk by chunk. I hope the Http client progressively writes to the stream to avoid being out of memory while downloading files. This was ok while using 'sink'... I can't make real life tests with big files. My internet connection is pretty weak :sob:. Let's hope it's sill ok.

I managed to import photos and drive files with SSE enabled, then see them correctly decrypted in NC web interface and download them.

julien-nc avatar Aug 30 '21 12:08 julien-nc

@eneiluj Thank you for your work. I tested this out and it worked well on SSE enabled NC instance :100:

I must confess that I used the nightly version on NC20 after changing <nextcloud min-version="20"> in info.xml file

Niveshkrishna avatar Sep 22 '21 14:09 Niveshkrishna

Im having the exact same issues on NC22.2.0 and just opened an issue about it on the help.nextcloud page before seeing this. (https://help.nextcloud.com/t/bad-signature-error-when-importing-files-from-google-onedrive-using-nextcloud-app/125785)

Any ETA on when this fix will be rolled out to stable builds?

ClaraCrazy avatar Oct 21 '21 16:10 ClaraCrazy

Feel free to reopen if needed.

julien-nc avatar Dec 23 '22 14:12 julien-nc