ijpiantanida / talkback

A simple HTTP proxy that records and playbacks requests
MIT License
284 stars 41 forks source link

Error when trying to connect to an https with self-signed certificate #30

Closed josejulio closed 5 years ago

josejulio commented 5 years ago

On my dev environment, I'm using openshift with a self-signed certificate (https), when trying to use this tool I get the following error: "reason: self signed certificate in certificate chain"

Is there a way to allow self-signed certificates?

{ url: '/api/auth/info',
  headers:
   { 'x-forwarded-host': 'localhost:3000',
     'x-forwarded-proto': 'http',
     'x-forwarded-port': '3000',
     'x-forwarded-for': '127.0.0.1',
     cookie:
      '_ga=GA1.1.1514412781.1557421740; Webstorm-a9376004=b9c98f11-f6b4-4bb3-84c3-0983d04fd04e; _gid=GA1.1.1489284077.1565034839',
     'accept-language': 'en,en-US;q=0.9,es-419;q=0.8,es;q=0.7',
     'accept-encoding': 'gzip, deflate, br',
     referer: 'http://localhost:3000/',
     'content-type': 'application/json;charset=utf-8',
     'user-agent':
      'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36',
     'x-auth-type-kiali-ui': '1',
     accept: 'application/json, text/plain, */*',
     connection: 'close',
     host: 'localhost:3030' } }
Making real request to https://kiali-istio-system.127.0.0.1.nip.io/api/auth/info
Error handling request { FetchError: request to https://kiali-istio-system.127.0.0.1.nip.io/api/auth/info failed, reason: self signed certificate in certificate chain
    at ClientRequest.<anonymous> (/home/josejulio/Documentos/redhat/kiali/kiali-mock-server/node_modules/node-fetch/lib/index.js:1455:11)
    at ClientRequest.emit (events.js:182:13)
    at TLSSocket.socketErrorListener (_http_client.js:392:9)
    at TLSSocket.emit (events.js:182:13)
    at emitErrorNT (internal/streams/destroy.js:82:8)
    at emitErrorAndCloseNT (internal/streams/destroy.js:50:3)
    at process._tickCallback (internal/process/next_tick.js:63:19)
  message:
   'request to https://kiali-istio-system.127.0.0.1.nip.io/api/auth/info failed, reason: self signed certificate in certificate chain',
  type: 'system',
  errno: 'SELF_SIGNED_CERT_IN_CHAIN',
  code: 'SELF_SIGNED_CERT_IN_CHAIN' }
josejulio commented 5 years ago

I was able to solve this by setting the following:

process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";