kriskbx / gitlab-time-tracker

🦊🕘 A command line interface for GitLab's time tracking feature.
GNU General Public License v2.0
452 stars 83 forks source link

Insecure mode does not work #125

Open jkonecny75 opened 3 years ago

jkonecny75 commented 3 years ago

We have a self-signed certificate. Due to I use --insecure parameter but DBG mode says that secure mode is still using

gtt report --insecure --verbose project/build
🔍  Resolving "project/build"... ✗
Error: Invalid access token!
{ RequestError: Error: self signed certificate in certificate chain
    at new RequestError (/snapshot/gitlab-time-tracker/node_modules/request-promise-core/lib/errors.js:14:15)
    at Request.module.exports.plumbing.callback (/snapshot/gitlab-time-tracker/node_modules/request-promise-core/lib/plumbing.js:87:29)
    at Request.RP$callback [as _callback] (/snapshot/gitlab-time-tracker/node_modules/request-promise-core/lib/plumbing.js:46:31)
    at Request.init.self.callback (/snapshot/gitlab-time-tracker/node_modules/request/request.js:185:22)
    at Request.emit (events.js:182:13)
    at Request.onRequestError (/snapshot/gitlab-time-tracker/node_modules/request/request.js:877:8)
    at ClientRequest.emit (events.js:182:13)
    at TLSSocket.socketErrorListener (_http_client.js:382:9)
    at TLSSocket.emit (events.js:182:13)
    at emitErrorNT (internal/streams/destroy.js:82:8)
  name: 'RequestError',
  message: 'Error: self signed certificate in certificate chain',
  cause:
   { Error: self signed certificate in certificate chain
       at TLSSocket.onConnectSecure (_tls_wrap.js:1055:34)
       at TLSSocket.emit (events.js:182:13)
       at TLSSocket._finishInit (_tls_wrap.js:635:8) code: 'SELF_SIGNED_CERT_IN_CHAIN' },
  error:
   { Error: self signed certificate in certificate chain
       at TLSSocket.onConnectSecure (_tls_wrap.js:1055:34)
       at TLSSocket.emit (events.js:182:13)
       at TLSSocket._finishInit (_tls_wrap.js:635:8) code: 'SELF_SIGNED_CERT_IN_CHAIN' },
  options:
   { json: true,
     insecure: false,
     resolveWithFullResponse: true,
     headers: { 'PRIVATE-TOKEN': 'my-token' },
     uri:
      'https://gitlab.ourcomapany.org:443/api/v4/broadcast_messages?private_token=my-token&page=1&per_page=100',
     callback: [Function: RP$callback],
     transform: undefined,
     simple: true,
     transform2xxOnly: false },
  response: undefined }

The workarround is to export evn NODE_TLS_REJECT_UNAUTHORIZED='0'