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

"Download failed" after upgrade to onlyoffice - unable to verify the first certificate #96

Closed
thomass4t opened this issue Apr 10, 2018 · 30 comments

Comments

@thomass4t
Copy link

I upgraded to the current community- and document-server 9.6.1.627
Community-Server runs with self-signed SSL certificate
Document-Server runs with plain http

After restart of the two docker containers, I get an error message when opening any kind of document. The error message merely shows "Download failed".

I discovered the underlying error within the logfile
/app/onlyoffice/DocumentServer/logs/documentserver/converter/out.log

Whenever I open a document, an error shows up in this logfile:

[2018-04-10 14:17:05.216] [ERROR] nodeJS - error downloadFile:url=https://onlyoffice/products/files/httphandlers/filehandler.ashx?action=stream&fileid=4&version=6&stream_auth=xxx;attempt=3;code:UNABLE_TO_VERIFY_LEAF_SIGNATURE;connect:undefined;(id=PryKqIixHZSmYe_LEsQ_)
Error: unable to verify the first certificate
at Error (native)
at TLSSocket. (_tls_wrap.js:1092:38)
at emitNone (events.js:86:13)
at TLSSocket.emit (events.js:185:7)
at TLSSocket._finishInit (_tls_wrap.js:609:8)
at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:439:38)

The document-Server seems to download something from the community-server and fails because it doesn't know the CA of the self-signed certificate.

How can I add my self-signed certificate or my CA to the document-server?
My CA must be injected to Node-JS service.
(Adding it to /etc/ssl/certs didn't work and also setting the docker-env NODE_TLS_REJECT_UNAUTHORIZED=0 didn't help either)

Thanks for any suggestions,
Thomas

@dmkash
Copy link

dmkash commented Jul 13, 2018

I am running into the same problem while setting up local virtual machines in our development environment. For our development virtual machines we use the .test TLD, so need to use self-signed certificates.

The ONLYOFFICE Document Server has been installed on a CentOS 7 virtual machine following the directions here: https://helpcenter.onlyoffice.com/server/linux/document/linux-installation-centos.aspx

I tried adding NODE_TLS_REJECT_UNAUTHORIZED=0 to the /etc/onlyoffice/documentserver/supervisor/onlyoffice-documentserver-docservice.ini but this didn't work, either. I'm seeing the exact same error in /var/log/onlyoffice/documentserver/docservice/out.log as the OP:

[2018-07-13 14:50:22.799] [ERROR] nodeJS - postData error: docId = 2_2_;url = https://testserver.ourdomain.test/path/to/document;data = {"key":"2_2_","status":1,"users":["1"],"actions":[{"type":1,"userid":1}]}
Error: self signed certificate
    at TLSSocket.<anonymous> (_tls_wrap.js:1105:38)
    at emitNone (events.js:106:13)
    at TLSSocket.emit (events.js:208:7)
    at TLSSocket._finishInit (_tls_wrap.js:639:8)
    at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:469:38)

@agolybev
Copy link
Contributor

Hi Dana, try turning off validating certificate by Document Server. Set services.CoAuthoring.requestDefaults.rejectUnauthorized=false in /etc/onlyoffice/documentserver/defaults.json file and restart documentserver serviceis with supervisorctl restart all.

@inpos
Copy link

inpos commented Aug 24, 2018

Unfortunately, node.js don't use system ca-certs and this issue can't be fixed by adding local CA cert to system bundle. Workaround by @agolybev work, but breaks SSL security due to allow connections to unauthorized ssl servers.

@thomaswollburg
Copy link

The workaround does work, but pretty pretty please update your documentation as I have tried all -e SSL_VERIFY_CLIENT="off" -e NODE_TLS_REJECT_UNAUTHORIZED=0 and what not to make this work. Can I invoice these useless hours of frustration somewhere? Even set up chain file and gave it the recommend name and everything. Nothing helped here.

@ibnpetr
Copy link
Contributor

ibnpetr commented Sep 26, 2018

@thomaswollburg
Next version of the DocumentServer container will include node.js v8, it does use system CA bundle, you will be able to import your certificates without having to disable verification.

@changchichung
Copy link

@ibnpetr is there any schedule for next release ?

@skuep
Copy link

skuep commented Jan 15, 2019

@ibnpetr
I am curious, are you already using node v8? When I execute the following in the onlyoffice docker container, I get:

docker exec <id> node -v
v8.14.0

However I am having the exact same issues as above. Also tried every workaround given above.

@mrwormo
Copy link

mrwormo commented Jun 26, 2019

Hi,
I'm using the latest docker image with Traefik as reverse proxy, and i have the same problem.

The trick to turning off validating certificate by Document Server works great :

Set services.CoAuthoring.requestDefaults.rejectUnauthorized=false in /etc/onlyoffice/documentserver/defaults.json file and restart documentserver serviceis with supervisorctl restart all.

But how can i modify the default.json when the container starts ? services.CoAuthoring.requestDefaults.rejectUnauthorized seems to not be modified by an environment variable (https://github.com/ONLYOFFICE/Docker-DocumentServer#available-configuration-parameters).

@ShockwaveNN
Copy link
Contributor

@mrwormo Hi, you're are right, not all options from default.json can be configured by params.
But you can use something like this after starting container

docker exec -it containerID /var/www/onlyoffice/documentserver/npm/node_modules/.bin/json -f /etc/onlyoffice/documentserver/default.json -I -e 'this.services.CoAuthoring.requestDefaults.rejectUnauthorized=false'

(I didn't check this exact command, but you should get an idea

@mrwormo
Copy link

mrwormo commented Jun 27, 2019

Hi @ShockwaveNN,
This command works just fine. Many thx !
Now i need to run the command when the container starts. I tried to put this line at the end of the Docker-compose.yml, but it doesn't work.
I continue to search a solution to automate this...

@ShockwaveNN
Copy link
Contributor

@mrwormo I think there is no elegant way to use this command witho Docker Compose, you can modify https://github.com/ONLYOFFICE/Docker-DocumentServer/blob/master/run-document-server.sh to add this command and rebuild image locally

@mrwormo
Copy link

mrwormo commented Jun 27, 2019

@ShockwaveNN I actually thought about modifying https://github.com/ONLYOFFICE/Docker-DocumentServer/blob/master/run-document-server.sh, and build my own image, but that means that we would have to rebuild the image each time we update.

@ShockwaveNN
Copy link
Contributor

@mrwormo I think you can try to move running run-document-server.sh command to docker-compose.yml file and add something like

command: >
    bash -c "/var/www/onlyoffice/documentserver/npm/node_modules/.bin/json -f /etc/onlyoffice/documentserver/default.json -I -e 'this.services.CoAuthoring.requestDefaults.rejectUnauthorized=false'
    && bash /app/onlyoffice/run-document-server.sh"

I didn't test it through

@mrwormo
Copy link

mrwormo commented Jul 1, 2019

@ShockwaveNN Thx for the time spent, but it doesn't work. Dont't bother, i will continue to edit the file after the container has started...

@ShockwaveNN
Copy link
Contributor

This issue is closed, seems original problem was resolved via update of nodejs to version 8
If not - I think it's better to create new issue

@ReinerNippes
Copy link
Contributor

ReinerNippes commented Nov 11, 2019

@ShockwaveNN

This issue is closed, seems original problem was resolved via update of nodejs to version 8
If not - I think it's better to create new issue

no. it's still not possible to use selfsigned certifcates.
and the workaround to change the file /etc/onlyoffice/documentserver/default.json inside the container would not survive an update. or?

ReinerNippes added a commit to ReinerNippes/Docker-DocumentServer that referenced this issue Nov 12, 2019
…ce - unable to verify the first certificate
agolybev pushed a commit that referenced this issue Dec 5, 2019
* fix issue #96 ; 'Download failed' after upgrade to onlyoffice - unable to verify the first certificate

* New variable name REJECT_UNAUTHORIZED_STORAGE

Shell variable rnamed to REJECT_UNAUTHORIZED_STORAGE.
@jcklpe
Copy link

jcklpe commented Dec 13, 2019

Can confirm that Reiner is correct. This issue wasn't fixed until I used the temporary fix.

agolybev added a commit that referenced this issue Dec 26, 2019
armagankaratosun added a commit to armagankaratosun/nextcloud that referenced this issue Nov 30, 2020
fixes the issue reported here ONLYOFFICE/Docker-DocumentServer#96 with self-signed certificates
@zner0L
Copy link

zner0L commented Jan 31, 2021

There actually is a way to do this properly and without disabling certificate verification. You can add your own CAs (or rather, replace nodejs' CA store) by adding them in the agentOptions of request, which takes in the options you can define in the TLS Secure Context:

"services.CoAuthoring.requestDefaults" {
    "agentOptions": {
        "ca": "<your pem style CA cert>"
    }
}

@nmaludy
Copy link

nmaludy commented Feb 5, 2021

@mrwormo I think you can try to move running run-document-server.sh command to docker-compose.yml file and add something like

command: >
    bash -c "/var/www/onlyoffice/documentserver/npm/node_modules/.bin/json -f /etc/onlyoffice/documentserver/default.json -I -e 'this.services.CoAuthoring.requestDefaults.rejectUnauthorized=false'
    && bash /app/onlyoffice/run-document-server.sh"

I didn't test it through

I got this working using a modified version of this suggestion, basically inserting the edit in the docker run command. Problem in the example above is trying to use /var/www/onlyoffice/documentserver/npm/node_modules/.bin/json that doesn't exist. Instead need to use /var/www/onlyoffice/documentserver/npm/bin/json:

docker run -i -t -d -p 8443:443  -v /var/www/onlyoffice/Data:/var/www/onlyoffice/Data \
  --entrypoint "/bin/bash" \
  onlyoffice/documentserver \
  -c "/var/www/onlyoffice/documentserver/npm/json -f /etc/onlyoffice/documentserver/default.json -I -e 'this.services.CoAuthoring.requestDefaults.rejectUnauthorized=false' && /app/ds/run-document-server.sh"

@lgzcoollg
Copy link

lgzcoollg commented Jan 9, 2022

@mrwormo I think you can try to move running run-document-server.sh command to docker-compose.yml file and add something like

command: >
    bash -c "/var/www/onlyoffice/documentserver/npm/node_modules/.bin/json -f /etc/onlyoffice/documentserver/default.json -I -e 'this.services.CoAuthoring.requestDefaults.rejectUnauthorized=false'
    && bash /app/onlyoffice/run-document-server.sh"

I didn't test it through

I got this working using a modified version of this suggestion, basically inserting the edit in the docker run command. Problem in the example above is trying to use /var/www/onlyoffice/documentserver/npm/node_modules/.bin/json that doesn't exist. Instead need to use /var/www/onlyoffice/documentserver/npm/bin/json:

docker run -i -t -d -p 8443:443  -v /var/www/onlyoffice/Data:/var/www/onlyoffice/Data \
  --entrypoint "/bin/bash" \
  onlyoffice/documentserver \
  -c "/var/www/onlyoffice/documentserver/npm/json -f /etc/onlyoffice/documentserver/default.json -I -e 'this.services.CoAuthoring.requestDefaults.rejectUnauthorized=false' && /app/ds/run-document-server.sh"

Docker tag:6.4, input command after docker run.and it work

@lgzcoollg
Copy link

@mrwormo I think you can try to move running run-document-server.sh command to docker-compose.yml file and add something like

command: >
    bash -c "/var/www/onlyoffice/documentserver/npm/node_modules/.bin/json -f /etc/onlyoffice/documentserver/default.json -I -e 'this.services.CoAuthoring.requestDefaults.rejectUnauthorized=false'
    && bash /app/onlyoffice/run-document-server.sh"

I didn't test it through

I got this working using a modified version of this suggestion, basically inserting the edit in the docker run command. Problem in the example above is trying to use /var/www/onlyoffice/documentserver/npm/node_modules/.bin/json that doesn't exist. Instead need to use /var/www/onlyoffice/documentserver/npm/bin/json:

docker run -i -t -d -p 8443:443  -v /var/www/onlyoffice/Data:/var/www/onlyoffice/Data \
  --entrypoint "/bin/bash" \
  onlyoffice/documentserver \
  -c "/var/www/onlyoffice/documentserver/npm/json -f /etc/onlyoffice/documentserver/default.json -I -e 'this.services.CoAuthoring.requestDefaults.rejectUnauthorized=false' && /app/ds/run-document-server.sh"

not work in docker image tags 7.0.0

@ShockwaveNN
Copy link
Contributor

You can now use docker env key USE_UNAUTHORIZED_STORAGE

@lgzcoollg
Copy link

You can now use docker env key USE_UNAUTHORIZED_STORAGE

Seccused!
-e USE_UNAUTHORIZED_STORAGE=true

@mrwormo
Copy link

mrwormo commented Feb 28, 2022

You can now use docker env key USE_UNAUTHORIZED_STORAGE

Yeah ! It's working with tag:6.4.2.
Not tested with tag:7

@webagroprom
Copy link

 #- LARGER_FILE_LIMITS=true
    ports:
      - '9050:80'
      - '9000:443'
    stdin_open: true
    restart: always
    stop_grace_period: 120s
    command: bash -c "/var/www/onlyoffice/documentserver/npm/json -f /etc/onlyoffice/documentserver/default.json -I -e 'this.services.CoAuthoring.requestDefaults.rejectUnauthorized=false' && bash /app/onlyoffice/run-document-server.sh"
    volumes:

Added to configuration docker-compose.yml launched container docker-compose up -d

nextcloud: Error while downloading the document file to be converted.) (версия 7.1.0.215)

What am I doing wrong ? How to solve this error?

@webagroprom
Copy link

@mrwormo I think you can try to move running run-document-server.sh command to docker-compose.yml file and add something like

command: >
    bash -c "/var/www/onlyoffice/documentserver/npm/node_modules/.bin/json -f /etc/onlyoffice/documentserver/default.json -I -e 'this.services.CoAuthoring.requestDefaults.rejectUnauthorized=false'
    && bash /app/onlyoffice/run-document-server.sh"

I didn't test it through

I got this working using a modified version of this suggestion, basically inserting the edit in the docker run command. Problem in the example above is trying to use /var/www/onlyoffice/documentserver/npm/node_modules/.bin/json that doesn't exist. Instead need to use /var/www/onlyoffice/documentserver/npm/bin/json:

docker run -i -t -d -p 8443:443  -v /var/www/onlyoffice/Data:/var/www/onlyoffice/Data \
  --entrypoint "/bin/bash" \
  onlyoffice/documentserver \
  -c "/var/www/onlyoffice/documentserver/npm/json -f /etc/onlyoffice/documentserver/default.json -I -e 'this.services.CoAuthoring.requestDefaults.rejectUnauthorized=false' && /app/ds/run-document-server.sh"

Docker tag:6.4, input command after docker run.and it work

Can you show an example of how to correctly add (as you added) data to the docker-compose.yml configuration file ?

@ShockwaveNN
Copy link
Contributor

@webagroprom I think for you it's better to create new discusttion\new issue since your problem doesn't seem any relation to original issue with certificate verification

@rasmu31
Copy link

rasmu31 commented Jun 7, 2022

Hello,

To resolve the same problem with Let's encrypt cert, I didn't modify onlyoffice configuration file default.json.
I only change ssl_certificate in nginx configuration file /etc/nginx/conf.d/ds.conf (onlyoffice general server block) :
ssl_certificate /etc/ssl/certs/fullchain.pem;
ssl_certificate_key /etc/ssl/private/privkey.pem;

pem files are from let's encrypt folder, I just copied them in /etc/ssl/certs/ and /etc/private/
When having the problem, I used cert.pem, now I use fullchain.pem and problem is gone.

See attachment : ds.conf.txt

@douglascrp
Copy link

You can now use docker env key USE_UNAUTHORIZED_STORAGE

Seccused! -e USE_UNAUTHORIZED_STORAGE=true

Yes, it works

@mirrornight
Copy link

You can now use docker env key USE_UNAUTHORIZED_STORAGE

not work in docker image tags onlyoffice/documentserver-de:7.3.3.50.

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

No branches or pull requests