0

I get an "ERR_INVALID_CERT_AUTH" error when an axios POST call is made. I tried to provide the root certificate string in httpsAgent but still get the same error. Please let me know what I might be doing wrong and how to fix it. The certificate was issued by CACert. Appreciate your help.

const caCrt = '<Certificate string>';
const httpsagent = new https.Agent({ ca: caCrt, keepAlive: false });

axios({
    method: 'post',
    url: urltocall,
    httpsAgent: httpsagent,
    data: JSON.stringify(inputJson),
    config: {
    headers: {
        'Access-Control-Allow-Origin': 'http://localhost:1337',
        'Accept': 'application/json',
        'Content-Type': 'application/json'
        }
    }
    })
    .then(function (response) {
    new Vue({
        components: { Home },
        render: h => h(Home, {
        props: {
            username: 'test
        }
        })
    }).$mount('#app');
    })
    .catch(function (error) {
    alert(error);
    });
Krishnan V S
  • 1,124
  • 1
  • 13
  • 31
  • You can try reading this https://stackoverflow.com/questions/51363855/how-to-configure-axios-to-use-ssl-certificate for some help. – Advait Toraskar Jul 13 '20 at 14:58
  • Thanks for your reply Advait. I had tried that but faced two challenges - 1) Could not find the package "fs" and so could not use "readFileSync". 2) Tried providing the certificate inline but still faced the same error. So not sure where I was going wrong – Krishnan V S Jul 13 '20 at 15:01

0 Answers0