自签名uri的角度https调用失败,并显示"net :: ERR_CERT_AUTHORITY_INVALID"; [英] Angular https call to self signed uri failing with "net::ERR_CERT_AUTHORITY_INVALID"
问题描述
我正在使用Angular http模块调用由自签名证书启用的https端点.
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);
});
}
}
Angular应用程序在chrome浏览器中运行时,将导致错误"net :: ERR_CERT_AUTHORITY_INVALID".此错误发生在this.http.get(...)方法调用上.
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.
节点的https模块具有下面显示的选项,并且似乎可以正常工作(来自
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
},
问题:是否可以在http.get调用期间禁用证书验证?
Question: Is it possible to disable certificate validation during http.get call?
推荐答案
不是,这是浏览器的限制.
Nope, This is a limitation from the browser.
您可以在浏览器中放置后端URL,以告诉您的浏览器授权此调用,然后它将起作用.
You can put the back end url in your browser to tell your browser to authorise this call, it will then work.
这篇关于自签名uri的角度https调用失败,并显示"net :: ERR_CERT_AUTHORITY_INVALID";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!