sha*_*ere 11 https self-signed angular
我正在使用 Angular http 模块调用由自签名证书启用的 https 端点。
代码类似于下面显示的内容:
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);
});
}
}
Run Code Online (Sandbox Code Playgroud)
当 angular 应用程序在 Chrome 浏览器中运行时,会导致错误“net::ERR_CERT_AUTHORITY_INVALID”。此错误发生在 this.http.get(...) 方法调用上。
Node 的 https 模块有一个如下所示的选项,它似乎可以工作(从这里输入链接描述:
var req = https.request({
host: '192.168.1.1',
port: 443,
path: '/',
method: 'GET',
rejectUnauthorized: false,
requestCert: true,
agent: false
},
Run Code Online (Sandbox Code Playgroud)
问题:是否可以在 http.get 调用期间禁用证书验证?
Deb*_*ppe 10
不,这是浏览器的限制。
您可以将后端 url 放在浏览器中以告诉浏览器授权此调用,然后它就会工作。
| 归档时间: |
|
| 查看次数: |
26416 次 |
| 最近记录: |