Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular https call to self signed uri failing with "net::ERR_CERT_AUTHORITY_INVALID"

I am using Angular http module to make a call to a https endpoint enabled by self signed certificate.

The code is similar to what is showng below:

    export class AppComponent {
  constructor(private  http: HttpClient) {
 }
  title = 'my-app';
    ngOnInit(): void {
        this.http.get('https://internalapp.com/context/apps/all').subscribe((res: any[]) => {
    console.log('sharief');
    console.log(res);
    });
  }
}

When angular application runs in chrome browser, it results in the error "net::ERR_CERT_AUTHORITY_INVALID". This error occurs on this.http.get(...) method call.

Node's https module has an option shown below and it seems to work (from enter link description here:

var req = https.request({ 
      host: '192.168.1.1', 
      port: 443,
      path: '/',
      method: 'GET',
      rejectUnauthorized: false,
      requestCert: true,
      agent: false
    },

Question: Is it possible to disable certificate validation during http.get call?

like image 857
shaiksphere Avatar asked Dec 05 '18 23:12

shaiksphere


People also ask

How do I add a self signed certificate as an exception in Chrome?

Open Chrome settings, scroll to the bottom, and click Show advanced settings... Click the Trusted Root Certification Authorities tab, then click the Import... button. This opens the Certificate Import Wizard.


1 Answers

Nope, This is a limitation from the browser.

You can put the back end url in your browser to tell your browser to authorise this call, it will then work.

like image 120
Deblaton Jean-Philippe Avatar answered Oct 21 '22 01:10

Deblaton Jean-Philippe