19

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?

Akber Iqbal
  • 14,487
  • 12
  • 48
  • 70
shaiksphere
  • 285
  • 1
  • 4
  • 12

1 Answers1

20

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.

Deblaton Jean-Philippe
  • 11,188
  • 3
  • 49
  • 66
  • 3
    Thanks for the reply. I am trying to understand what you said here. Did you mean to say that I have to open another tab in the browser, copy the back-end-url, override the resulting browser warning? – shaiksphere Dec 06 '18 at 00:20
  • Please ignore my follow-up question. I found another link https://stackoverflow.com/questions/51537394/how-to-add-selfsigned-certificate-to-chrome-mozilla which discusses the problem and suggested solution. May not be a good solution for sensitive and production environments. Valid (not self signed) certificates should be used instead. – shaiksphere Dec 06 '18 at 00:55
  • 2
    Your first question was right. If you think you can rephrase my answer, feel free to do it. My english is not perfect and I did my best to answer you ;-) – Deblaton Jean-Philippe Dec 06 '18 at 08:45