我在lambda中使用AWS.HttpRequest来调用HTTPS终端节点,但出现此错误:
Error: unable to get local issuer certificate
at TLSSocket.<anonymous> (_tls_wrap.js:1105:38)
at emitNone (events.js:106:13)
at TLSSocket.emit (events.js:208:7)
at TLSSocket._finishInit (_tls_wrap.js:639:8)
at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:469:38) code: 'UNABLE_TO_GET_ISSUER_CERT_LOCALLY'
在使用AWS.HttpRequest时,我找不到有关特定于HTTPS调用的操作的任何信息。
基本上,我的代码是这样的(很琐碎):
const req = new AWS.HttpRequest(url, region);
req.method = 'POST';
req.path = '/_bulk';
req.body = doc;
req.headers['Content-Type'] = 'application/json';
req.headers.Host = endpoint.host;
const send = new AWS.NodeHttpClient();
send.handleRequest(req, null, (httpResp) => {
let body = '';
httpResp.on('data', (chunk) => {
body += chunk;
});
httpResp.on('end', () => {
resolve({ response: httpResp, body });
});
}, (err) => {
reject(err);
});
如果端点是HTTP(相同的端点,仅在端口80上),则代码可以正常工作,但是如果我通过HTTPS端点,则会引发该错误。
更新:我用https
节点库替换了AWS.HttpRequest,并得到了相同的错误。好像我缺少什么。
答案 0 :(得分:-1)
请尝试如下所示的AWS祝贺
{
Accesskey:your_access_key,
Region: region_name,
sslEnabled:false
}