box / boxcli

A command line interface for interacting with the Box API.
https://developer.box.com
Apache License 2.0
228 stars 59 forks source link

self signed certificate in certificate chain #537

Closed w9y9x closed 2 months ago

w9y9x commented 4 months ago

Description of the Issue

I installed box cli in linux environment and configured config.json, but when I run the box users:get command, an error message appears: self-signed certificate in certificate chain, but the box version is normal. How can I bypass SSL verification, or where should I download the certificate from?

Steps to Reproduce

  1. npm install --global @box/cli
  2. box configure:environments:add /root/config.json
  3. box version
  4. box users:get self-signed certificate in certificate chain

Expected Behavior

User information should appear normally

Error Message, Including Stack Trace

self signed certificate in certificate chain

Screenshots

error

Versions Used

Box CLI: @box/cli/3.14.1 linux-x64 node-v18.10.0 Operating System: Red Hat Enterprise Linux release 8.10 (Ootpa)

arjankowski commented 4 months ago

Hi @w9y9x,

The issue you're experiencing is most likely due to the proxy server using its own certificate, which is not trusted. To resolve this issue, you can try one of the following options:

1) Add an environment variable: Set the environment variable NODE_TLS_REJECT_UNAUTHORIZED=0, as described here: GitHub Issue #276.

2) Add the self-signed certificate to trusted certificates: Download the self-signed certificate and add it to Node.js trusted certificates by setting the following environment variable:

export NODE_EXTRA_CA_CERTS=/path/to/certificate.pem

The best way to obtain the certificate is to request it from your proxy server administrator. If this is not possible, you can try to download it yourself by running the command:

openssl s_client -connect <PROXY_SERVER_ADDRESS:PORT> -showcerts </dev/null 2>/dev/null | openssl x509 -outform PEM > downloaded_cert.pem

In your case, it should look like this:

openssl s_client -connect PITC-Zscaler-China-Shanghai-IDC-HC.proxy.corporate.ge.com:80 -showcerts </dev/null 2>/dev/null | openssl x509 -outform PEM > downloaded_cert.pem

I hope this helps! Artur

w9y9x commented 4 months ago

thank you for your reply I tried setting the environment variable NODE_TLS_REJECT_UNAUTHORIZED=0, but it didn't seem to solve my problem

error

I also tried adding the trusted certificate in nodejs, but it didn't seem to work. Is there any other suitable solution?

option2_1 option2_2
lukaszsocha2 commented 4 months ago

Hi @w9y9x, can you ask your proxy provider for the root self-signed certificate and then try to apply it again? Best, @lukaszsocha2

w9y9x commented 3 months ago

Do you know where I can get the self-signed certificate for box cli if I'm not using a proxy?

error
stale[bot] commented 2 months ago

This issue has been automatically marked as stale because it has not been updated in the last 30 days. It will be closed if no further activity occurs within the next 7 days. Feel free to reach out or mention Box SDK team member for further help and resources if they are needed.

stale[bot] commented 2 months ago

This issue has been automatically closed due to maximum period of being stale. Thank you for your contribution to Box CLI and feel free to open another PR/issue at any time.