ladjs / superagent

Ajax for Node.js and browsers (JS HTTP client). Maintained for @forwardemail, @ladjs, @spamscanner, @breejs, @cabinjs, and @lassjs.
https://ladjs.github.io/superagent/
MIT License
16.58k stars 1.33k forks source link

Strange error with https request #1628

Open sujai1009 opened 3 years ago

sujai1009 commented 3 years ago

Hi Team,

When i try to call the https url with disableTLSCerts both my error and success callbacks are being called.

in failure::Hostname/IP does not match certificate's altnames: Host: te-alm-34816742102591475476959.qa.com. is not cert's CN: qa_java (node:75086) UnhandledPromiseRejectionWarning: Error [ERR_TLS_CERT_ALTNAME_INVALID]: Hostname/IP does not match certificate's altnames: Host: te-alm.qa.com. is not cert's CN: stage2_unifiedjava at Object.checkServerIdentity (tls.js:297:12) at TLSSocket.onConnectSecure (_tls_wrap.js:1507:27) at TLSSocket.emit (events.js:315:20) at TLSSocket._finishInit (_tls_wrap.js:932:8) at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:706:12) (node:75086) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 4)

in success 2::200:::

CODE:

return req.send(sampleReq.postData) .then(res => { if (sampleReq.callBackFn !== undefined) { return sampleReq.callBackFn(res.body) } else { console.log("in success 2::" + res.status + ":::" + res.text); return res.body; } }) .catch((err) => { console.log("in failure::" + err.message); throw err; });