admin管理员组文章数量:1243097
I wanted to make simple POST HTTP request by using request
module:
var request = require("request");
var form = {form: {some: "form", attributes: "attrs"}}
request.post("", form)
.on('response', function(response) {
if (response.statusCode === 200) {
console.log("DONE");
} else {
console.log("FAIL");
}
});
When I launch this code it throws me this error message:
Error: unable to verify the first certificate
at Error (native)
at TLSSocket.<anonymous> (_tls_wrap.js:1057:38)
at emitNone (events.js:67:13)
at TLSSocket.emit (events.js:166:7)
at TLSSocket._finishInit (_tls_wrap.js:596:8)
I think this is happening because url has https
, but I don't know how to fix this error.
How to disable checking certificate?
I wanted to make simple POST HTTP request by using request
module:
var request = require("request");
var form = {form: {some: "form", attributes: "attrs"}}
request.post("https://example.", form)
.on('response', function(response) {
if (response.statusCode === 200) {
console.log("DONE");
} else {
console.log("FAIL");
}
});
When I launch this code it throws me this error message:
Error: unable to verify the first certificate
at Error (native)
at TLSSocket.<anonymous> (_tls_wrap.js:1057:38)
at emitNone (events.js:67:13)
at TLSSocket.emit (events.js:166:7)
at TLSSocket._finishInit (_tls_wrap.js:596:8)
I think this is happening because url has https
, but I don't know how to fix this error.
How to disable checking certificate?
Share Improve this question asked Mar 24, 2016 at 6:20 Mr.DMr.D 7,87315 gold badges69 silver badges126 bronze badges 1- 2 Possible duplicate of Error: unable to verify the first certificate in nodejs – CodingDefined Commented Mar 24, 2016 at 8:33
2 Answers
Reset to default 6Add "rejectUnauthorized": false
as option:
request.post({url: "https://example.", "rejectUnauthorized": false}, form)
.on('response', function(response) {
if (response.statusCode === 200) {
console.log("DONE");
} else {
console.log("FAIL");
}
});
Or add the appropiate certificate via https://www.npmjs./package/ssl-root-cas
require('ssl-root-cas').inject();
You can try with disabling ssl certificate verification under File->Settings Settings image
本文标签: javascriptRequestError unable to verify the first certificateStack Overflow
版权声明:本文标题:javascript - Request, Error: unable to verify the first certificate - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1740072939a2223145.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论