serviejs / popsicle

Simple HTTP requests for node and the browser
MIT License
246 stars 19 forks source link

ERROR EUNAVAILABLE for self signed certificate #132

Open qaniel opened 4 years ago

qaniel commented 4 years ago

When trying to connect to an internal identity server for OAuth authentication using https (self-signed) the library gives a misleading error of EUNAVAILABLE. popsicle version 12.0.4

{
  "request" : {
    "trailer" : {

    },
    "$rawBody" : "scope=SCOPE&grant_type=GRANT_TYPE",
    "method" : "POST",
    "url" : "https://domain.com/connect/token",
    "signal" : {
      "_" : [

      ],
      "$" : {
        "abort" : [
          null,
          null,
          null
        ]
      },
      "aborted" : false
    },
    "headers" : {
      "object" : {
        "user-agent" : "Popsicle (https://github.com/serviejs/popsicle)",
        "accept" : "application/json, application/x-www-form-urlencoded",
        "content-type" : "application/x-www-form-urlencoded",
        "authorization" : "Basic AUTH_CODE",
        "content-length" : "41",
        "accept-encoding" : "gzip, deflate, br"
      }
    }
  },
  "stack" : "ConnectionError: Unable to connect to domain.com:443\n    at TLSSocket.onError (/var/www/html/project/node_modules/popsicle-transport-http/src/index.ts:706:15)\n    at Object.onceWrapper (events.js:418:26)\n    at TLSSocket.emit (events.js:311:20)\n    at emitErrorNT (internal/streams/destroy.js:92:8)\n    at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)\n    at processTicksAndRejections (internal/process/task_queues.js:84:21)",
  "code" : "EUNAVAILABLE"
} 

Note that I'm able to wget https://domain.com:443 --no-check-certificate and receive a successful response. Also, it works when using regular Http

blakeembrey commented 4 years ago

That’s reasonable. Is this bug report that the error should be improved? There’s an option already that allows you to connect to self signed certificates in the transport layer.