Answer the question
In order to leave comments, you need to log in
Why doesn't Axios accept an SSL certificate (unable to verify the first certificate)?
I create a REST API on a website, SSL is accepted by the browser, Encryption Everywhere is released.
When trying to make a request from the program via Axios, it throws an error:
Error: unable to verify the first certificate
at TLSSocket.onConnectSecure (_tls_wrap.js:1058:34)
at TLSSocket.emit (events.js:198:13)
at TLSSocket.EventEmitter.emit (domain.js:448:20)
at TLSSocket._finishInit(_tls_wrap.js:636:8)
const agent = new https.Agent({
rejectUnauthorized: false,
ca: fs.readFileSync("./certificate.crt")
});
(async() => {
console.log(await axios.get('http://site.ru/api.php'), {httpsAgent: agent});
})()
Answer the question
In order to leave comments, you need to log in
Study the issue deeper and figure out:
- either what root certificate store is used in this code fragment (it’s not at all a fact that the place where you put it is used as a root certificate store, besides, don’t forget to make links)
- or how to disable validation (force to accept any certificate). This, of course, is a so-so solution, it’s impossible to sell it, but for testing, so as not to slow down at this place, it will do.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question