undefined
undefined

Reputation: 3632

How to ignore self signed certificate issue in request-promise

I am using request-promise module for my node app to make some API call. https://www.npmjs.com/package/request-promise

import request from 'request-promise';
let options = {
                method: GET,
                json: true,
                uri : "https://" +this.urls + endpoint,
                body: payload,
                rejectUnauthorized: false // This doesn't work
            };

let response = await request(options)

SInce the API what I am trying to use is insecure (having self signed certificate), the conncetion is failing with this error:

Error: connect ECONNREFUSED

I know with "request" module, we could pass rejectUnauthorized: false , to handle such case. I am not sure how can I pass such option with request-promise module.

Upvotes: 2

Views: 11530

Answers (2)

Lan Nguyen
Lan Nguyen

Reputation: 465

For any one still searching for this: add strictSSL: false to the options object works for me

Upvotes: 11

prabushitha
prabushitha

Reputation: 1483

Try adding this to top of your code. But this approach is insecure.

process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";

Upvotes: 4

Related Questions