question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Axios, https and self-signed certificates

See original GitHub issue

Hi, I’m using axios from vue typescript over https to a web api that returns a self signed cert, but I can’t get axios to ignore cert errors that are then reported by the browser. I have tried suggestions from other posts (that have now been closed) as follows below but just get cert errors reported in the console and nothing on the page until I accept the cert from the console (chrome and FF, Edge won’t do anything and needs Fiddler).

Here is the a snippet from main.ts…

axios.interceptors.request.use((config) => {
    const https = require('https');
    // https.globalAgent.options.rejectUnauthorized = false;  // doesn't work, options is undefined.
    config.httpsAgent = new https.Agent({ rejectUnauthorised: false }); 
    config.baseURL = 'https://addr/';
    return config;
},
    (err) =>
    {
        console.log('AXIOS Interceptor: Error returned: ' + err);
    });

This is from home.vue because the main,ts interceptor code doesn’t work…

	async getInfo(siteCode: string): Promise<any> {

                const infoEndpoint = 'site-by-code/' + siteCode;
                const https = require('https');
                try
                {
                    const agent = new https.Agent({
                        rejectUnauthorized: false,
                    });
                    const response = await this.$http.get(this.serviceBase + infoEndpoint, { httpsAgent: agent });
                    return response.data;
                } catch (err) {
                    console.log(err);
                }
                return null;
           },

Cheers.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:10 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
flrklicommented, Jun 12, 2019

Thanks for your replies. This was exactly what I was expecting and it helps me to clarify things.

0reactions
jasonsaaymancommented, Jun 11, 2019

I doubt we should be removing the need to validate SSL or have a bypass for this. When developing locally and using a self-signed certificate you would only need to add this certificate to the browser once and it will be remembered for all future requests.

Should you be using a self-signed certificate on your web host I would suggest you look into a good free SSL provider, else your users will also need to whitelist the SSL certificate. Either way, this is not an Axios issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to configure axios to use SSL certificate? - Stack Overflow
Axios is an http(s) client and http clients usually participate in TLS ... If the service has a private SSL cert (self signed...
Read more >
How to ignore SSL issues #535 - axios/axios - GitHub
Actually, I find that it does work, but it specifically addresses self-signed certificates. It does not allow expired or invalid certificates.
Read more >
Axios & Proxy Manager - Error: self signed certificate ... - Reddit
I'm trying to fetch an URL body using Axios and Brightdata as a proxy (via proxy-manager hosted locally). const axios = require('axios'); const ......
Read more >
Securely Connecting Node.js and Axios (JS) Using Mutual TLS
A Complete Guide to Securely Connecting Node.js and Axios (JS) Using ... In your https server, specify the location of your CA root...
Read more >
Connect to API's in enterprise closed network using axios in ...
This is the solution that let me consume intranet APIs for self-hosted tools You probably use every day. First create httpsAgent that will...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found