问题描述
我正在尝试调用一个REST URL,该URL仅返回主证书,而不返回中级和根CA。我尝试使用以下代码添加证书。中间件和rootca都被复制到同一文件中。但是,面对错误消息“ 无法验证第一个证书”
,这种方法似乎不起作用:float
根CA嵌入了中间证书和根证书。
解决方法
此问题通过添加证书来解决。
const fs = require('fs');
var https = require('https');
sslrootCAs.addFile('Path to rootCA.cer');
sslrootCAs.addFile('Path to intermediate.cer')
https.globalAgent.options.ca = sslrootCAs;
const httpagent = new https.Agent({
rejectUnauthorized: false,})
axios.get('REST URL',{httpagent})