的NodeJS 'DEPTH
我得到上面的错误,当我尝试用Node.js的客户,我在此刻TE写连接到网络服务器。
但是,我得到一个错误,当我尝试连接到服务器。
'DEPTH_ZERO_SELF_SIGNED_CERT'
这是发送请求的代码。并关闭证书检查是不是有效选项。我需要保护的连接。
var options =
{
hostname: baseUri,
port: 443,
path: 'oauth',
method: 'POST',
requestCert: true,
ca:fs.readFileSync('Comodo_PositiveSSL_bundle.crt'),
rejectUnauthorized: true,
headers: {
//'User-Agent': USER_AGENT,
'Content-Type': 'application/x-www-form-urlencoded',
'Content-Length': data.length
}
};
var req = http.request(options, (res) => {
console.log('statusCode: ', res.statusCode);
console.log('headers: ', res.headers);
res.on('data', (d) => {
process.stdout.write(d);
});
});
req.write(data)
req.end();
req.on('error', (e) => {
console.error(e);
});
如果有人能告诉我如何我可以设置认证正确,从而不会产生错误?
该证书捆绑的图片。正如你可以看到包中只包含根证书需要验证服务器提供本身的证书。
回答如下:问题是由下面的代码解决。我已经加入options.agent = http.Agent(options);
and说解决了这个问题。
所以对于大家谁是试图验证到一个安全的服务器,并得到上述错误,这可能是您的解决方案。下面,我已经添加了上述的编辑的代码。
var options =
{
hostname: baseUri,
port: 443,
path: 'oauth',
method: 'POST',
requestCert: true,
headers: {
//'User-Agent': USER_AGENT,
'Content-Type': 'application/x-www-form-urlencoded',
'Content-Length': data.length
}
};
options.agent = http.Agent(options);
var req = http.request(options, (res) => {
console.log('statusCode: ', res.statusCode);
console.log('headers: ', res.headers);
res.on('data', (d) => {
process.stdout.write(d);
});
});
req.write(data)
req.end();
req.on('error', (e) => {
console.error(e);
});
的NodeJS 'DEPTH
我得到上面的错误,当我尝试用Node.js的客户,我在此刻TE写连接到网络服务器。
但是,我得到一个错误,当我尝试连接到服务器。
'DEPTH_ZERO_SELF_SIGNED_CERT'
这是发送请求的代码。并关闭证书检查是不是有效选项。我需要保护的连接。
var options =
{
hostname: baseUri,
port: 443,
path: 'oauth',
method: 'POST',
requestCert: true,
ca:fs.readFileSync('Comodo_PositiveSSL_bundle.crt'),
rejectUnauthorized: true,
headers: {
//'User-Agent': USER_AGENT,
'Content-Type': 'application/x-www-form-urlencoded',
'Content-Length': data.length
}
};
var req = http.request(options, (res) => {
console.log('statusCode: ', res.statusCode);
console.log('headers: ', res.headers);
res.on('data', (d) => {
process.stdout.write(d);
});
});
req.write(data)
req.end();
req.on('error', (e) => {
console.error(e);
});
如果有人能告诉我如何我可以设置认证正确,从而不会产生错误?
该证书捆绑的图片。正如你可以看到包中只包含根证书需要验证服务器提供本身的证书。
回答如下:问题是由下面的代码解决。我已经加入options.agent = http.Agent(options);
and说解决了这个问题。
所以对于大家谁是试图验证到一个安全的服务器,并得到上述错误,这可能是您的解决方案。下面,我已经添加了上述的编辑的代码。
var options =
{
hostname: baseUri,
port: 443,
path: 'oauth',
method: 'POST',
requestCert: true,
headers: {
//'User-Agent': USER_AGENT,
'Content-Type': 'application/x-www-form-urlencoded',
'Content-Length': data.length
}
};
options.agent = http.Agent(options);
var req = http.request(options, (res) => {
console.log('statusCode: ', res.statusCode);
console.log('headers: ', res.headers);
res.on('data', (d) => {
process.stdout.write(d);
});
});
req.write(data)
req.end();
req.on('error', (e) => {
console.error(e);
});