【问题标题】:Why am I obtaining this ERR_CERT_AUTHORITY_INVALID error calling an HTTPS API using a self signed certificate from an Angular service?为什么我使用来自 Angular 服务的自签名证书调用 HTTPS API 时会出现此 ERR_CERT_AUTHORITY_INVALID 错误?
【发布时间】:2019-04-17 14:42:56
【问题描述】:

我在尝试从 Angular 服务调用外部 REST HTTPS API 时遇到以下问题:

我有这个 Angular 服务:

@Injectable()
export class MailDetailProtocolloService {

    private protocolloAooApiUrl = 'https://myservercom:443/my_project/api/GetDeparmentsList';  

    constructor(
        private http: HttpClient
    )
    {
    }

    /** GET AOO List chiamando un'API esterna */

    getAooList(): Observable<Aoo[]> {
        return this.http.get<Aoo[]>(this.protocolloAooApiUrl)
    }

}

问题在于此 API 使用 自签名证书 并调用它我在控制台中收到此错误消息:

GET https://myservercom:443/my_project/api/GetDeparmentsList net::ERR_CERT_AUTHORITY_INVALID

为什么?如何修复它并使用此自签名证书调用它?

【问题讨论】:

    标签: angular rxjs angular5 javascript-framework angular-http


    【解决方案1】:

    默认情况下,浏览器不接受自签名证书。您的计算机上安装了一个受信任的证书颁发机构(简称“CA”)列表,允许颁发证书。为了让您的计算机信任您的证书,您必须手动将您的 CA 添加到此信任列表或直接安装自签名证书。

    如何执行此操作取决于您的操作系统和浏览器。

    Here is the tutorial for Windows

    Here is the turorial for Mac

    Here is the tutorial for Linux

    与“胖客户端”不同,Web 应用程序无法自动执行此操作;这是所有现代浏览器的默认安全策略。想象一下,一个网站可以在后台向恶意网站发送敏感数据。

    【讨论】:

      猜你喜欢
      • 2020-02-16
      • 1970-01-01
      • 2018-03-03
      • 2020-01-05
      • 1970-01-01
      • 2013-11-09
      • 1970-01-01
      • 2019-07-22
      • 2019-03-16
      相关资源
      最近更新 更多