Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid PDF structure on shared files #207

Closed
CamZie opened this issue Aug 7, 2020 · 52 comments
Closed

Invalid PDF structure on shared files #207

CamZie opened this issue Aug 7, 2020 · 52 comments

Comments

@CamZie
Copy link

CamZie commented Aug 7, 2020

Steps to reproduce

  1. user shares link of a PDF file
  2. opens the PDF shared by link
  3. gets error "Invalid or corrupted file | Message: Invalid PDF structure"

Expected behaviour

shows and can download PDF file through the shared link without any problems

Actual behaviour

receives error when opening and downloading the PDF file:
image

The owner of the shared link can access the PDFs so it does not seem to be corrupted. Also re-shared the PDF and still same problem occurs.

Server configuration

Operating system: Debian 9.13 (stretch)

Web server: nginx 1.10.3

Database: MariaDB 10.1.45

PHP version: 7.2

Nextcloud version: NC 18.0.6

Updated from an older Nextcloud/ownCloud or fresh install: updated from an older version

Where did you install Nextcloud from: Nextcloud website

Signing status:

Signing status
No errors have been found.

List of activated apps:

App list
Enabled:
  - accessibility: 1.4.0
  - activity: 2.11.0
  - admin_audit: 1.8.0
  - apporder: 0.10.0
  - bruteforcesettings: 1.6.0
  - calendar: 2.0.3
  - cloud_federation_api: 1.1.0
  - comments: 1.8.0
  - contacts: 3.3.0
  - dav: 1.14.0
  - drop_account: 0.2.1
  - encryption: 2.6.0
  - external: 3.5.0
  - federatedfilesharing: 1.8.0
  - federation: 1.8.0
  - files: 1.13.1
  - files_pdfviewer: 1.7.0
  - files_rightclick: 0.15.2
  - files_sharing: 1.10.1
  - files_trashbin: 1.8.0
  - files_videoplayer: 1.7.0
  - logreader: 2.3.0
  - lookup_server_connector: 1.6.0
  - notes: 3.5.1
  - notifications: 2.6.0
  - oauth2: 1.6.0
  - password_policy: 1.8.0
  - photos: 1.0.0
  - provisioning_api: 1.8.0
  - quota_warning: 1.7.0
  - recommendations: 0.6.0
  - serverinfo: 1.8.0
  - settings: 1.0.0
  - sharebymail: 1.8.0
  - tasks: 0.13.1
  - text: 2.0.0
  - theming: 1.9.0
  - twofactor_backupcodes: 1.7.0
  - twofactor_totp: 4.1.3
  - updatenotification: 1.8.0
  - viewer: 1.2.0
  - workflowengine: 2.0.0

Nextcloud configuration:

Config report
    "system": {
        "instanceid": "***REMOVED SENSITIVE VALUE***",
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "datadirectory": "***REMOVED SENSITIVE VALUE***",
        "dbtype": "mysql",
        "version": "18.0.6.0",
        "dbname": "***REMOVED SENSITIVE VALUE***",
        "dbhost": "***REMOVED SENSITIVE VALUE***",
        "dbtableprefix": "oc_",
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "installed": true,
        "forcessl": true,
        "enable_avatars": false,
        "mail_domain": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpmode": "smtp",
        "log_authfailip": true,
        "loglevel": 2,
        "maintenance": false,
        "customclient_desktop": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": [
            "***REMOVED SENSITIVE VALUE***"
        ],
        "share_folder": "\/Shared",
        "overwritewebroot": "\/",
        "overwriteprotocol": "https",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "singleuser": false,
        "memcache.local": "\\OC\\Memcache\\APCu",
        "trashbin_retention_obligation": "auto,30",
        "activity_expire_days": 14,
        "logtimezone": "Europe\/Zurich",
        "log_type": "errorlog",
        "skeletondirectory": "\/var\/www\/nextcloud\/themes\/core\/skeleton",
        "overwrite.cli.url": "***REMOVED SENSITIVE VALUE***",
        "mail_from_address": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpauthtype": "LOGIN",
        "preview_max_scale_factor": 1,
        "preview_max_filesize_image": 3,
        "preview_max_x": 1024,
        "preview_max_y": 1024,
        "mysql.utf8mb4": true,
        "app_install_overwrite": [
            "drop_account"
        ]
    }

Are you using encryption: yes

Client configuration

Browser: Chrome, Firefox

Operating system: Linux / Windows

Logs

Web server error log

Web server error log
no errors

Nextcloud log (data/nextcloud.log)

Nextcloud log
PHP message: [owncloud][no app in context][3] {"Exception":"OC\\Encryption\\Exceptions\\DecryptionFailedException","Message":"Can not decrypt this file, probably this is a shared file. Please ask the file owner to reshare the file with you.","Code":0,"Trace":[{"file":"/var/www/nextcloud/lib/private/Files/Stream/Encryption.php","line":507,"function":"decrypt","class":"OCA\\Encryption\\Crypto\\Encryption","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/nextcloud/lib/private/Files/Stream/Encryption.php","line":302,"function":"readCache","class":"OC\\Files\\Stream\\Encryption","type":"->","args":[]},{"function":"stream_read","class":"OC\\Files\\Stream\\Encryption","type":"->","args":[8192]},{"file":"/var/www/nextcloud/3rdparty/icewind/streams/src/Wrapper.php","line":91,"function":"fread","args":[null,8192]},{"file":"/var/www/nextcloud/3rdparty/icewind/streams/src/CallbackWrapper.php","line":98,"function":"stream_read","class":"Icewind\\Streams\\Wrapper","type":"->","args":[8192" while reading response header from upstream, client: ***REMOVED_SENSITIVE_CONTENT***, server: ***REMOVED_SENSITIVE_CONTENT***, request: "GET /s/tHTmJY64XCQQyr3/download HTTP/2.0", upstream: "fastcgi://unix:/var/run/php-fpm.sock:", host: "***REMOVED_SENSITIVE_CONTENT***"

Browser log

Browser log
util.js:306 Warning: Ignoring invalid character "33" in hex string
util.js:306 Warning: Ignoring invalid character "79" in hex string
util.js:306 Warning: Ignoring invalid character "84" in hex string
util.js:306 Warning: Ignoring invalid character "89" in hex string
util.js:306 Warning: Ignoring invalid character "80" in hex string
util.js:306 Warning: Ignoring invalid character "104" in hex string
util.js:306 Warning: Ignoring invalid character "116" in hex string
util.js:306 Warning: Ignoring invalid character "109" in hex string
util.js:306 Warning: Ignoring invalid character "108" in hex string
util.js:306 Warning: Ignoring invalid character "104" in hex string
util.js:306 Warning: Ignoring invalid character "116" in hex string
util.js:306 Warning: Ignoring invalid character "109" in hex string
2util.js:306 Warning: Ignoring invalid character "108" in hex string
2util.js:306 Warning: Ignoring invalid character "115" in hex string
util.js:306 Warning: Ignoring invalid character "61" in hex string
util.js:306 Warning: Ignoring invalid character "34" in hex string
util.js:306 Warning: Ignoring invalid character "110" in hex string
util.js:306 Warning: Ignoring invalid character "103" in hex string
util.js:306 Warning: Ignoring invalid character "45" in hex string
util.js:306 Warning: Ignoring invalid character "115" in hex string
util.js:306 Warning: Ignoring invalid character "112" in hex string
util.js:306 Warning: Ignoring invalid character "34" in hex string
util.js:306 Warning: Ignoring invalid character "116" in hex string
util.js:306 Warning: Ignoring invalid character "45" in hex string
util.js:306 Warning: Ignoring invalid character "112" in hex string
util.js:306 Warning: Ignoring invalid character "108" in hex string
util.js:306 Warning: Ignoring invalid character "104" in hex string
util.js:306 Warning: Ignoring invalid character "111" in hex string
util.js:306 Warning: Ignoring invalid character "108" in hex string
util.js:306 Warning: Ignoring invalid character "114" in hex string
util.js:306 Warning: Ignoring invalid character "45" in hex string
util.js:306 Warning: Ignoring invalid character "111" in hex string
util.js:306 Warning: Ignoring invalid character "117" in hex string
util.js:306 Warning: Ignoring invalid character "115" in hex string
util.js:306 Warning: Ignoring invalid character "61" in hex string
util.js:306 Warning: Ignoring invalid character "34" in hex string
util.js:306 Warning: Ignoring invalid character "108" in hex string
util.js:306 Warning: Ignoring invalid character "115" in hex string
util.js:306 Warning: Ignoring invalid character "34" in hex string
util.js:306 Warning: Ignoring invalid character "108" in hex string
util.js:306 Warning: Ignoring invalid character "110" in hex string
util.js:306 Warning: Ignoring invalid character "103" in hex string
util.js:306 Warning: Ignoring invalid character "61" in hex string
util.js:306 Warning: Ignoring invalid character "34" in hex string
util.js:306 Warning: Ignoring invalid character "110" in hex string
util.js:306 Warning: Ignoring invalid character "34" in hex string
util.js:306 Warning: Ignoring invalid character "116" in hex string
util.js:306 Warning: Ignoring invalid character "45" in hex string
util.js:306 Warning: Ignoring invalid character "108" in hex string
util.js:306 Warning: Ignoring invalid character "111" in hex string
util.js:306 Warning: Ignoring invalid character "108" in hex string
util.js:306 Warning: Ignoring invalid character "61" in hex string
util.js:306 Warning: Ignoring invalid character "34" in hex string
util.js:306 Warning: Ignoring invalid character "110" in hex string
util.js:306 Warning: Ignoring invalid character "34" in hex string
util.js:306 Warning: Ignoring invalid character "104" in hex string
util.js:306 Warning: Ignoring invalid character "116" in hex string
util.js:306 Warning: Ignoring invalid character "45" in hex string
util.js:306 Warning: Ignoring invalid character "114" in hex string
util.js:306 Warning: Ignoring invalid character "113" in hex string
util.js:306 Warning: Ignoring invalid character "117" in hex string
util.js:306 Warning: Ignoring invalid character "115" in hex string
2util.js:306 Warning: Ignoring invalid character "116" in hex string
util.js:306 Warning: Ignoring invalid character "111" in hex string
util.js:306 Warning: Ignoring invalid character "107" in hex string
util.js:306 Warning: Ignoring invalid character "110" in hex string
util.js:306 Warning: Ignoring invalid character "61" in hex string
2util.js:306 Warning: Ignoring invalid character "34" in hex string
util.js:306 Warning: Ignoring invalid character "109" in hex string
util.js:306 Warning: Ignoring invalid character "116" in hex string
util.js:306 Warning: Ignoring invalid character "104" in hex string
util.js:306 Warning: Ignoring invalid character "114" in hex string
util.js:306 Warning: Ignoring invalid character "115" in hex string
util.js:306 Warning: Ignoring invalid character "116" in hex string
util.js:306 Warning: Ignoring invalid character "61" in hex string
util.js:306 Warning: Ignoring invalid character "34" in hex string
util.js:306 Warning: Ignoring invalid character "117" in hex string
util.js:306 Warning: Ignoring invalid character "116" in hex string
util.js:306 Warning: Ignoring invalid character "45" in hex string
util.js:306 Warning: Ignoring invalid character "34" in hex string
util.js:306 Warning: Ignoring invalid character "116" in hex string
util.js:306 Warning: Ignoring invalid character "105" in hex string
util.js:306 Warning: Ignoring invalid character "116" in hex string
util.js:306 Warning: Ignoring invalid character "108" in hex string
util.js:306 Warning: Ignoring invalid character "33" in hex string
util.js:306 Warning: Ignoring invalid character "79" in hex string
util.js:306 Warning: Ignoring invalid character "84" in hex string
util.js:306 Warning: Ignoring invalid character "89" in hex string
util.js:306 Warning: Ignoring invalid character "80" in hex string
util.js:306 Warning: Ignoring invalid character "104" in hex string
util.js:306 Warning: Ignoring invalid character "116" in hex string
util.js:306 Warning: Ignoring invalid character "109" in hex string
util.js:306 Warning: Ignoring invalid character "108" in hex string
util.js:306 Warning: Ignoring invalid character "104" in hex string
util.js:306 Warning: Ignoring invalid character "116" in hex string
util.js:306 Warning: Ignoring invalid character "109" in hex string
2util.js:306 Warning: Ignoring invalid character "108" in hex string
2util.js:306 Warning: Ignoring invalid character "115" in hex string
util.js:306 Warning: Ignoring invalid character "61" in hex string
util.js:306 Warning: Ignoring invalid character "34" in hex string
util.js:306 Warning: Ignoring invalid character "110" in hex string
util.js:306 Warning: Ignoring invalid character "103" in hex string
util.js:306 Warning: Ignoring invalid character "45" in hex string
util.js:306 Warning: Ignoring invalid character "115" in hex string
util.js:306 Warning: Ignoring invalid character "112" in hex string
util.js:306 Warning: Ignoring invalid character "34" in hex string
util.js:306 Warning: Ignoring invalid character "116" in hex string
util.js:306 Warning: Ignoring invalid character "45" in hex string
util.js:306 Warning: Ignoring invalid character "112" in hex string
util.js:306 Warning: Ignoring invalid character "108" in hex string
util.js:306 Warning: Ignoring invalid character "104" in hex string
util.js:306 Warning: Ignoring invalid character "111" in hex string
util.js:306 Warning: Ignoring invalid character "108" in hex string
util.js:306 Warning: Ignoring invalid character "114" in hex string
util.js:306 Warning: Ignoring invalid character "45" in hex string
util.js:306 Warning: Ignoring invalid character "111" in hex string
util.js:306 Warning: Ignoring invalid character "117" in hex string
util.js:306 Warning: Ignoring invalid character "115" in hex string
util.js:306 Warning: Ignoring invalid character "61" in hex string
util.js:306 Warning: Ignoring invalid character "34" in hex string
util.js:306 Warning: Ignoring invalid character "108" in hex string
util.js:306 Warning: Ignoring invalid character "115" in hex string
util.js:306 Warning: Ignoring invalid character "34" in hex string
util.js:306 Warning: Ignoring invalid character "108" in hex string
util.js:306 Warning: Ignoring invalid character "110" in hex string
util.js:306 Warning: Ignoring invalid character "103" in hex string
util.js:306 Warning: Ignoring invalid character "61" in hex string
util.js:306 Warning: Ignoring invalid character "34" in hex string
util.js:306 Warning: Ignoring invalid character "110" in hex string
util.js:306 Warning: Ignoring invalid character "34" in hex string
util.js:306 Warning: Ignoring invalid character "116" in hex string
util.js:306 Warning: Ignoring invalid character "45" in hex string
util.js:306 Warning: Ignoring invalid character "108" in hex string
util.js:306 Warning: Ignoring invalid character "111" in hex string
util.js:306 Warning: Ignoring invalid character "108" in hex string
util.js:306 Warning: Ignoring invalid character "61" in hex string
util.js:306 Warning: Ignoring invalid character "34" in hex string
util.js:306 Warning: Ignoring invalid character "110" in hex string
util.js:306 Warning: Ignoring invalid character "34" in hex string
util.js:306 Warning: Ignoring invalid character "104" in hex string
util.js:306 Warning: Ignoring invalid character "116" in hex string
util.js:306 Warning: Ignoring invalid character "45" in hex string
util.js:306 Warning: Ignoring invalid character "114" in hex string
util.js:306 Warning: Ignoring invalid character "113" in hex string
util.js:306 Warning: Ignoring invalid character "117" in hex string
util.js:306 Warning: Ignoring invalid character "115" in hex string
2util.js:306 Warning: Ignoring invalid character "116" in hex string
util.js:306 Warning: Ignoring invalid character "111" in hex string
util.js:306 Warning: Ignoring invalid character "107" in hex string
util.js:306 Warning: Ignoring invalid character "110" in hex string
util.js:306 Warning: Ignoring invalid character "61" in hex string
2util.js:306 Warning: Ignoring invalid character "34" in hex string
util.js:306 Warning: Indexing all PDF objects
app.js:692 Uncaught (in promise) Error: Invalid or corrupted PDF file.
    at app.js:692
@CamZie
Copy link
Author

CamZie commented Aug 10, 2020

This problem also affects shared files that are .zip. The error appears when trying to download the file:

Can not decrypt this file, probably this is a shared file. Please ask the file owner to reshare the file with you.

The file has also been re-shared and was also re-uploaded but still the same problem.

@CamZie
Copy link
Author

CamZie commented Aug 13, 2020

This problem also affect images shared through the shared link. It produces the same error as well when trying to download or access the file.

Is there any news regarding this? This problem is affecting multiple users at the same time...

@CamZie
Copy link
Author

CamZie commented Aug 25, 2020

Can someone please help here?

This issue is getting critical, because suddenly it is now happening on our other 18.0.6 installation that worked before. Our last upgrade was still on June, which is why Its weird because we not did not do changes here and have tried to reproduce the problem here before and everything seems to be fine and now suddenly this problem appears....

Opening some PDF files that are shared by link are getting the same "Invalid PDF structure" error and on the server errors regarding the encryption appears.

2020/08/25 08:54:27 [error] 527#527: *12078651 FastCGI sent in stderr: "PHP message: [owncloud][no app in context][3] {"Exception":"OCA\\Encryption\\Exceptions\\MultiKeyDecryptException","Message":"multikeydecrypt with share key failed:error:0407109F:rsa routines:RSA_padding_check_PKCS1_type_2:pkcs decoding error","Code":0,"Trace":[{"file":"/var/www/nextcloud/apps/encryption/lib/KeyManager.php","line":450,"function":"multiKeyDecrypt","class":"OCA\\Encryption\\Crypto\\Crypt","type":"->","args":[null,null,"-----BEGIN PRIVATE KEY-----\" while reading response header from upstream, client: ***REMOVED***, server: ***REMOVED***, request: "GET /s/PfabYPtBKmDDfkg/download HTTP/2.0", upstream: "fastcgi://unix:/var/run/php-fpm.sock:", host: "***REMOVED***"

@skjnldsv skjnldsv transferred this issue from nextcloud/server Aug 25, 2020
@skjnldsv
Copy link
Member

Can you open it properly from regular files? Not from a share?

@CamZie
Copy link
Author

CamZie commented Aug 25, 2020

@skjnldsv Yes, accessing the files normally as the user is working fine. The problem only occurs if the files are opened through a shared link.

@skjnldsv
Copy link
Member

Have you disabled federated sharing?

@CamZie
Copy link
Author

CamZie commented Aug 25, 2020

We have the following federated sharing enabled:
image

@skjnldsv
Copy link
Member

I will need a screenshot of your network requests.
Before you do anything, still on the development tools, there is a tab called network. Click on it and then the pdf GET request. Do your action and screenshot the network log like this:
capture d ecran_2018-09-27_21-49-46

@skjnldsv
Copy link
Member

If you can also screenshot the preview tab after you clicked the request, it would be nice :)
Thanks!

@CamZie
Copy link
Author

CamZie commented Aug 25, 2020

Thanks! Please let me know if there is anything else you need

network_logs

@skjnldsv
Copy link
Member

Can you click the last one?
Is your pdf 5.5KB?

@skjnldsv
Copy link
Member

Also, might be fixed in latest nc20, since we moved the pdfviewer 🤔

@CamZie
Copy link
Author

CamZie commented Aug 25, 2020

This is the preview of the PDF file and it should be 297KB.

preview

@CamZie
Copy link
Author

CamZie commented Aug 25, 2020

Also, please take note that this does not only happen for PDF files but also for .zip and photos that are shared through link

Also, might be fixed in latest nc20, since we moved the pdfviewer thinking

@hostingnuggets
Copy link

Also, might be fixed in latest nc20, since we moved the pdfviewer thinking

@skjnldsv could you please confirm that this issue is fixed with Nextcloud 20? Your sentence above only states "might", which is not quite clear... Could you also please backport this fix to Nextcloud 18/19 as I also have this issue and it is affecting a lot of users on my installation too.

@skjnldsv
Copy link
Member

Also, might be fixed in latest nc20, since we moved the pdfviewer thinking

@skjnldsv could you please confirm that this issue is fixed with Nextcloud 20? Your sentence above only states "might", which is not quite clear... Could you also please backport this fix to Nextcloud 18/19 as I also have this issue and it is affecting a lot of users on my installation too.

I cannot as this is a super edge case and I haven't the time to set this up :)
We upgraded the PDF viewer to latest versions and it now uses the nextcloud Viewer!

@CamZie
Copy link
Author

CamZie commented Aug 28, 2020

@skjnldsv So are there any updates regarding this or any workaround for this issue or do we have to wait until Nextcloud 20 has been released? Will this also solve the problems with the .zip files and images files?

Is it possible that this has to do something with our server side encryption with user keys?

@skjnldsv
Copy link
Member

I cannot tell. This is out of my league for the encryption part.

What zip and images issue are you referring to?

@CamZie
Copy link
Author

CamZie commented Aug 28, 2020

The issue with the zip and images are the same with the PDF files. The user can open/download it if opened normally but if it is through the shared link it gives the same error as the PDFs.

This problem also affects shared files that are .zip. The error appears when trying to download the file:

Can not decrypt this file, probably this is a shared file. Please ask the file owner to reshare the file with you.

The file has also been re-shared and was also re-uploaded but still the same problem.

This problem also affect images shared through the shared link. It produces the same error as well when trying to download or access the file.

Is there any news regarding this? This problem is affecting multiple users at the same time...

@skjnldsv
Copy link
Member

skjnldsv commented Aug 28, 2020

The issue with the zip and images are the same with the PDF files. The user can open/download it if opened normally but if it is through the shared link it gives the same error as the PDFs.

This problem also affects shared files that are .zip. The error appears when trying to download the file:

Can not decrypt this file, probably this is a shared file. Please ask the file owner to reshare the file with you.

The file has also been re-shared and was also re-uploaded but still the same problem.

This problem also affect images shared through the shared link. It produces the same error as well when trying to download or access the file.

Is there any news regarding this? This problem is affecting multiple users at the same time...

@rullzer @blizzz @MorrisJobke is it a known issue for encryption?

@hostingnuggets

This comment has been minimized.

@CamZie
Copy link
Author

CamZie commented Sep 10, 2020

Hello everyone, are there any updates regarding the issue with shared files?

@CamZie
Copy link
Author

CamZie commented Sep 22, 2020

We have now upgraded our installation to version 18.0.9 and still the same problem with the shared files... Are there any updates regarding this problem?

@CamZie
Copy link
Author

CamZie commented Nov 6, 2020

Hello, any news regarding this problem?

We have noticed that this mainly affects our installation with server-side encryption with user-keys. Were there any changes regarding the sharing function for this kind of encryption?

@skjnldsv
Copy link
Member

skjnldsv commented Nov 6, 2020

Sorry, this is unfortunately not in our current priorities :(

@skjnldsv
Copy link
Member

skjnldsv commented Nov 7, 2020

@CamZie what is the full path of the file?
#254

@CamZie
Copy link
Author

CamZie commented Nov 9, 2020

@skjnldsv I have now sent an email with the shared links. Thanks in advance for the help.

@skjnldsv
Copy link
Member

skjnldsv commented Nov 9, 2020

@yahesh
Copy link
Member

yahesh commented Nov 9, 2020

Yeah, turns out this is not possible thinking
https://docs.nextcloud.com/server/stable/user_manual/en/files/encrypting_files.html#sharing-encrypted-files

I'd argue against that. Nextcloud allows to publicly share SSE encrypted files by means of the pubShare keypair. The link you provided relates to user key encryption in cases where not all user keypairs have been generated. However, the pubShare keypair should be generated as soon as the SSE is enabled.

@skjnldsv
Copy link
Member

skjnldsv commented Nov 9, 2020

I have no clue to be honest, but it seems that it is disabled.
This is not an issue about pdfviewer, downloading is impossible as well.

@yahesh
Copy link
Member

yahesh commented Nov 9, 2020

@CamZie Could have a look into your data directory whether you have files called files_encryption/OC_DEFAULT_MODULE/pubShare_$random.publicKey and files_encryption/OC_DEFAULT_MODULE/pubShare_$random.privateKey in there where $random is a random identifier? After you shared a file through a link, could you also have a look whether you can find a file called $username/files_encryption/keys/files/$filename/OC_DEFAULT_MODULE/pubShare_$random.shareKey where $username is the owner of the shared file, $filename is name of the shared file and $random is the same random identifier as before?

@CamZie
Copy link
Author

CamZie commented Nov 10, 2020

@yahesh As requested, I confirm that the files are existing and the random identifier of the keys are the same, which i replaced here with abcd1234:

data/files_encryption/OC_DEFAULT_MODULE/pubShare_abcd1234.privateKey  
data/files_encryption/OC_DEFAULT_MODULE/pubShare_abcd1234.publicKey

<USERNAME>/files_encryption/keys/files/document.pdf/OC_DEFAULT_MODULE/pubShare_abcd1234.shareKey

@yahesh
Copy link
Member

yahesh commented Nov 10, 2020

Then Nextcloud should be able to decrypt the file when it is accessed through the share link.

@skjnldsv
Copy link
Member

I'm out of ideas, does it work for you @yahesh ?

@ozboss
Copy link

ozboss commented Nov 29, 2020

So I noticed I get this error if I try to open a pdf file in a folder with '#' prepended (e.g. /#testfolder). I can view the pdf without issues if it is placed in a folder like /testfolder. So special characters in the link / folder structure are causing this???

@yahesh
Copy link
Member

yahesh commented Dec 2, 2020

So I noticed I get this error if I try to open a pdf file in a folder with '#' prepended (e.g. /#testfolder). I can view the pdf without issues if it is placed in a folder like /testfolder. So special characters in the link / folder structure are causing this???

Generally, folder and file names containing hash signs (#) and question marks (?) seem to break the PDF viewer. The percentage sign (%) completely prevents the PDF viewer from opening at all. I assume that this stems from some kind of escaping problem as these characters have special meanings in URLs. The web console also mentions a URIError in Viewer.vue:274.

I also checked ampersand (&) and equal (=) signs but they did not lead to a problem.

@skjnldsv
Copy link
Member

skjnldsv commented Dec 2, 2020

nextcloud/viewer#415

@CamZie
Copy link
Author

CamZie commented Dec 4, 2020

We are also aware of the problems with folder/file names containing special characters. But this is not cause of our issue because we are not using any special characters in the names.

@JBM888
Copy link

JBM888 commented Feb 8, 2021

Hello,
I'm experiancing the same problem having PDF's getting corrupted when trying to view them as shared with read only no download rights. The strange thing is that it worked initially but then stoped. I have tried to get it to work again by moving the firectory out of its initial path since that had a character that, according to reasoning earlier in the thread, could be an issue.
I'm currently running NextCloud 20.0.7 which appears healthy on a Raspberry.

Regards!
/JBM

@baltaner
Copy link

baltaner commented Feb 8, 2021

Hello,
I've nearly the same problems here.
Thoe problem occur ONLY when the PDF-File is in an public shared folder with password protection (enforced). Whene I download this file the file opens without any problems!

When I share the same PDF-File directly (not inside a shared folder) it works as expected - I get the correct view of the PDF-File inside the browser!

I hope this helps to isolate the problem.

Best regards
Bertold

@nderambure
Copy link

nderambure commented Feb 8, 2021

Hello,

Same problem here, I have a folder with a PDF inside , and if I'm connected to my account and click the PDF : no problem, the PDF is previewed.
But if I share the folder with a public link, and then go to this link and try to open the PDF, it fails with the error described above.

Using Nextcloud 20.0.7 on Debian 10 / Apache / Mariadb up to date.

screenshot_error_pdfviewer

@bigahuna
Copy link

Steps to reproduce

  • user shares link of a folder containing multiple PDF files
  • opens the folder shared by link
  • opens a pdf file
  • gets error "Invalid or corrupted file | Message: Invalid PDF structure"
  • download of the file works, the file can then be opened in multiple pdf viewers locally (Acrobat reader, Macos preview, google chrome, firefox)

Expected behaviour

  • shows and can download PDF file through the shared link without any problems

Actual behaviour
After Updating from nextcloud 20.0.6 to 20.0.7 a click on a pdf file in a shared folder produces the following error:

Bildschirmfoto 2021-02-10 um 13 29 02

The same files can be opened without problems inside non shared folders. This is reproducable.

Server configuration
Operating system: Centos 7 latest
Web server: Apache/2.4.6 (CentOS)
Database: MariaDB 10.3.27
PHP version: 7.4.14
Nextcloud version: NC 20.0.7

@dst21
Copy link

dst21 commented Feb 10, 2021

Same here after Update to Nextcloud 20.0.7.> Message: Invalid PDF structure.

In the meantime I will set Onlyoffice as the default PDF viewer.

@bigahuna
Copy link

That doesn't work either. Opening PDFs with OnlyOffice in the shared folder results in this error:
Bildschirmfoto 2021-02-10 um 14 32 14

Open PDFs with OnlyOffice in a non shared folder works just fine. The Path to the PDF files is corrupted inside shared folders, so the app to view them does not matter because they can't be opened-

@dst21
Copy link

dst21 commented Feb 10, 2021

This is peculiar. For me, the view works in a shared folder with OnlyOffice

@misterscrooby
Copy link

Same problem here in Nextcloud 20.0.7. It only occoures in shared folder via links.

@nderambure
Copy link

I seems @wankdanker has a patch for this, Kudos to him : #309

@nderambure
Copy link

Patch has been made, adapting original one, and seems to be delivered soon in stable release, see #319

@ThinkOli
Copy link

I HAD the same problem. Resolved with the help of this discussion ...

We ran server side encryption and ran into some issues with accessing shared files. Given we're running encryption on the filesystem, we decided to abandon NC encryption and I ran thru the process:
cd /var/www/html/nextcloud/
sudo -u www-data php occ encryption:decrypt-all
sudo -u www-data php occ maintenance:mode --on
sudo -u www-data php occ encryption:disable
sudo -u www-data php occ maintenance:mode --off

Unfortunately, not all files got decrypted. I had to learn that a lot of data remained encrypted. But status of encryption was 'enabled: false'. I.e. I could not simply rerun the decryption. After
sudo -u www-data php occ maintenance:mode --on
sudo -u www-data php occ encryption:enable
sudo -u www-data php occ maintenance:mode --off
sudo -u www-data php occ encryption:decrypt-all
upon successfull completion of the last step (after several hours), encryption got disabled again, and all data became accessible.

I have to say that I ssh'ed into the server and experienced some disconnections, i.e. the process could not be completed within a single step. With every reconnect, encryption had got disabled, and I had to start the above procedure. But when it came back with the system prompt, everything is now working well.

Whether we'll decide on leveraging server side encryption again in the future, remains to be seen. So far, for us it did not work reliably.

@rmdes
Copy link

rmdes commented Oct 18, 2022

I noticed this issue is closed but this bug is still happening for some reason, so here is my temporary approach to have sharing links to work, without embeds.

I have tried some of the advices listed in this thread but none of them could help me get at the same time, sharing to work, PDF to embed and files to be downloadable.

The issue is clearly the PDFjs viewer because the moment this app is disabled, files can be downloaded just fine and sharing link works perfectly.

So this is my temporary fix for this bug, disable PDF Viewer

Version :
Nextcloud 24.0.4
files not encrypted
basically a default Nextcloud.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests