如何忽略请求中的自签名证书问题 [英] How to ignore self signed certificate issue in request-promise
问题描述
我正在为我的节点应用程序使用请求承诺模块来进行一些API调用. https://www.npmjs.com/package/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)
由于我要使用的API不安全(具有自签名证书),因此连接失败并显示以下错误:
SInce the API what I am trying to use is insecure (having self signed certificate), the conncetion is failing with this error:
错误:连接ECONNREFUSED
Error: connect ECONNREFUSED
我知道使用"request"模块,我们可以传递rejectUnauthorized:false来处理这种情况.我不确定如何通过请求承诺模块传递此类选项.
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.
推荐答案
对于仍在搜索此内容的任何人:
将strictSSL: false
添加到options对象对我有用
For any one still searching for this:
add strictSSL: false
to the options object works for me
这篇关于如何忽略请求中的自签名证书问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!