zoukankan      html  css  js  c++  java
  • How Certificate Chains Work 证书链如何工作的

    How Certificate Chains Work

    Solution

    What is a Certificate Chain?

    • A certificate chain is an ordered list of certificates, containing an SSL/TLS Certificate and Certificate Authority (CA) Certificates, that enable the receiver to verify that the sender and all CA's are trustworthy. 
    • The chain or path begins with the SSL/TLS certificate, and each certificate in the chain is signed by the entity identified by the next certificate in the chain.


    What is an Intermediate Certificate?

    • Any certificate that sits between the SSL/TLS Certificate and the Root Certificate is called a chain or Intermediate Certificate. 
    • The Intermediate Certificate is the signer/issuer of the SSL/TLS Certificate. 
    • The Root CA Certificate is the signer/issuer of the Intermediate Certificate. 
    • If the Intermediate Certificate is not installed on the server (where the SSL/TLS certificate is installed) it may prevent some browsers, mobile devices, applications, etc. from trusting the SSL/TLS certificate. 
    • In order to make the SSL/TLS certificate compatible with all clients, it is necessary that the Intermediate Certificate be installed.

     

    What is the Root CA Certificate?

    The chain terminates with a Root CA Certificate. The Root CA Certificate is always signed by the CA itself. The signatures of all certificates in the chain must be verified up to the Root CA Certificate.


    Illustration of a certification path from the certificate owner to the Root CA, where the chain of trust begins:

    Solution

    What is a Certificate Chain?

    • A certificate chain is an ordered list of certificates, containing an SSL/TLS Certificate and Certificate Authority (CA) Certificates, that enable the receiver to verify that the sender and all CA's are trustworthy. 
    • The chain or path begins with the SSL/TLS certificate, and each certificate in the chain is signed by the entity identified by the next certificate in the chain.


    What is an Intermediate Certificate?

    • Any certificate that sits between the SSL/TLS Certificate and the Root Certificate is called a chain or Intermediate Certificate. 
    • The Intermediate Certificate is the signer/issuer of the SSL/TLS Certificate. 
    • The Root CA Certificate is the signer/issuer of the Intermediate Certificate. 
    • If the Intermediate Certificate is not installed on the server (where the SSL/TLS certificate is installed) it may prevent some browsers, mobile devices, applications, etc. from trusting the SSL/TLS certificate. 
    • In order to make the SSL/TLS certificate compatible with all clients, it is necessary that the Intermediate Certificate be installed.

     

    What is the Root CA Certificate?

    The chain terminates with a Root CA Certificate. The Root CA Certificate is always signed by the CA itself. The signatures of all certificates in the chain must be verified up to the Root CA Certificate.


    Illustration of a certification path from the certificate owner to the Root CA, where the chain of trust begins:

    https://zhuanlan.zhihu.com/p/344086342

    数字证书和 CA 机构

    在说校验数字证书是否可信的过程前,我们先来看看数字证书是什么,一个数字证书通常包含了:

    • 公钥;
    • 持有者信息
    • 证书认证机构(CA)的信息;
    • CA 对这份文件的数字签名及使用的算法;
    • 证书有效期;
    • 还有一些其他额外信息;

    那数字证书的作用,是用来认证公钥持有者的身份,以防止第三方进行冒充。说简单些,证书就是用来告诉客户端,该服务端是否是合法的,因为只有证书合法,才代表服务端身份是可信的。

    我们用证书来认证公钥持有者的身份(服务端的身份),那证书又是怎么来的?又该怎么认证证书呢?

    为了让服务端的公钥被大家信任,服务端的证书都是由 CA (Certificate Authority,证书认证机构)签名的,CA 就是网络世界里的公安局、公证中心,具有极高的可信度,所以由它来给各个公钥签名,信任的一方签发的证书,那必然证书也是被信任的。

    之所以要签名,是因为签名的作用可以避免中间人在获取证书时对证书内容的篡改。

    数字证书签发和验证流程

    如下图图所示,为数字证书签发和验证流程:

    CA 签发证书的过程,如上图左边部分:

    • 首先 CA 会把持有者的公钥、用途、颁发者、有效时间等信息打成一个包,然后对这些信息进行 Hash 计算,得到一个 Hash 值;
    • 然后 CA 会使用自己的私钥将该 Hash 值加密,生成 Certificate Signature,也就是 CA 对证书做了签名;
    • 最后将 Certificate Signature 添加在文件证书上,形成数字证书;

    客户端校验服务端的数字证书的过程,如上图右边部分:

    • 首先客户端会使用同样的 Hash 算法获取该证书的 Hash 值 H1;
    • 通常浏览器和操作系统中集成了 CA 的公钥信息,浏览器收到证书后可以使用 CA 的公钥解密 Certificate Signature 内容,得到一个 Hash 值 H2 ;
    • 最后比较 H1 和 H2,如果值相同,则为可信赖的证书,否则则认为证书不可信。

     

    证书链

    但事实上,证书的验证过程中还存在一个证书信任链的问题,因为我们向 CA 申请的证书一般不是根证书签发的,而是由中间证书签发的,比如百度的证书,从下图你可以看到,证书的层级有三级:

    对于这种三级层级关系的证书的验证过程如下:

    • 客户端收到 baidu.com 的证书后,发现这个证书的签发者不是根证书,就无法根据本地已有的根证书中的公钥去验证 baidu.com 证书是否可信。于是,客户端根据 baidu.com 证书中的签发者,找到该证书的颁发机构是 “GlobalSign Organization Validation CA - SHA256 - G2”,然后向 CA 请求该中间证书
    • 请求到证书后发现 “GlobalSign Organization Validation CA - SHA256 - G2” 证书是由 “GlobalSign Root CA” 签发的,由于 “GlobalSign Root CA” 没有再上级签发机构,说明它是根证书,也就是自签证书。应用软件会检查此证书有否已预载于根证书清单上,如果有,则可以利用根证书中的公钥去验证 “GlobalSign Organization Validation CA - SHA256 - G2” 证书,如果发现验证通过,就认为该中间证书是可信的。
    • “GlobalSign Organization Validation CA - SHA256 - G2” 证书被信任后,可以使用 “GlobalSign Organization Validation CA - SHA256 - G2” 证书中的公钥去验证 baidu.com 证书的可信性,如果验证通过,就可以信任 baidu.com 证书。

    在这四个步骤中,最开始客户端只信任根证书 GlobalSign Root CA 证书的,然后 “GlobalSign Root CA” 证书信任 “GlobalSign Organization Validation CA - SHA256 - G2” 证书,而 “GlobalSign Organization Validation CA - SHA256 - G2” 证书又信任 baidu.com 证书,于是客户端也信任 baidu.com证书。

    总括来说,由于用户信任 GlobalSign,所以由 GlobalSign 所担保的 baidu.com 可以被信任,另外由于用户信任操作系统或浏览器的软件商,所以由软件商预载了根证书的 GlobalSign 都可被信任。

     

    这样的一层层地验证就构成了一条信任链路,整个证书信任链验证流程如下图所示:

    最后一个问题,为什么需要证书链这么麻烦的流程?Root CA 为什么不直接颁发证书,而是要搞那么多中间层级呢?

    这是为了确保根证书的绝对安全性,将根证书隔离地越严格越好,不然根证书如果失守了,那么整个信任链都会有问题。

     

     

     

  • 相关阅读:
    ORA-01536: 超出表空间 'tablespace_name' 的空间限额
    Oracle数据库表索引失效,解决办法:修改Oracle数据库优化器模式
    解决response.setHeader("Content-disposition" 中文乱码问题
    MyBatis配置:在控制台打印SQL语句
    JS 字符串转日期格式 日期格式化字符串
    远程桌面管理工具Remote Desktop Connection Manager
    调整Windows操作系统下时间同步的频率
    Oracle数据库中字符型字段按数字排序
    “Error:(1, 1) java: 非法字符: 'ufeff'”错误解决办法
    本次孩子流感总结
  • 原文地址:https://www.cnblogs.com/chucklu/p/15673195.html
Copyright © 2011-2022 走看看