X.509概况

X.509基础结构

这里写图片描述
end entity: user of PKI certificates and/or end user system that is
the subject of a certificate;

CA: certification authority;

RA: registration authority, i.e., an optional system to which
a CA delegates certain management functions;

CRL issuer: a system that generates and signs CRLs; and

repository: a system or collection of distributed systems that stores
certificates and CRLs and serves as a means of
distributing these certificates and CRLs to end entities

Example

Certificate  ::=  SEQUENCE  {
        tbsCertificate       TBSCertificate,
        signatureAlgorithm   AlgorithmIdentifier,
        signatureValue       BIT STRING  }

   TBSCertificate  ::=  SEQUENCE  {
        version         [0]  EXPLICIT Version DEFAULT v1,
        serialNumber         CertificateSerialNumber,
        signature            AlgorithmIdentifier,
        issuer               Name,
        validity             Validity,
        subject              Name,
        subjectPublicKeyInfo SubjectPublicKeyInfo,
        issuerUniqueID  [1]  IMPLICIT UniqueIdentifier OPTIONAL,
                             -- If present, version MUST be v2 or v3

        subjectUniqueID [2]  IMPLICIT UniqueIdentifier OPTIONAL,
                             -- If present, version MUST be v2 or v3
        extensions      [3]  EXPLICIT Extensions OPTIONAL
                             -- If present, version MUST be v3
        }

   Version  ::=  INTEGER  {  v1(0), v2(1), v3(2)  }

   CertificateSerialNumber  ::=  INTEGER

   Validity ::= SEQUENCE {
        notBefore      Time,
        notAfter       Time }

   Time ::= CHOICE {
        utcTime        UTCTime,
        generalTime    GeneralizedTime }

   UniqueIdentifier  ::=  BIT STRING

   SubjectPublicKeyInfo  ::=  SEQUENCE  {
        algorithm            AlgorithmIdentifier,
        subjectPublicKey     BIT STRING  }

   Extensions  ::=  SEQUENCE SIZE (1..MAX) OF Extension

   Extension  ::=  SEQUENCE  {
        extnID      OBJECT IDENTIFIER,
        critical    BOOLEAN DEFAULT FALSE,
        extnValue   OCTET STRING
                    -- contains the DER encoding of an ASN.1 value
                    -- corresponding to the extension type identified
                    -- by extnID
        }

这里写图片描述

End Entity Certificate Using RSA

This appendix contains an annotated hex dump of a 629-byte version 3
certificate. The certificate contains the following information:

(a) the serial number is 18;
(b) the certificate is signed with RSA and the SHA-1 hash algorithm;
(c) the issuer’s distinguished name is
cn=Example CA,dc=example,dc=com;
(d) the subject’s distinguished name is
cn=End Entity,dc=example,dc=com;
(e) the certificate was valid from September 15, 2004 through March
15, 2005;
(f) the certificate contains a 1024-bit RSA public key;
(g) the certificate is an end entity certificate, as the basic
constraints extension is not present;
(h) the certificate contains an authority key identifier extension
matching the subject key identifier of the certificate in
appendix C.1; and
(i) the certificate includes one alternative name – an electronic
mail address (rfc822Name) of “end.entity@example.com”.

0  625: SEQUENCE {
   4  474:   SEQUENCE {
   8    3:     [0] {
  10    1:       INTEGER 2 //version 3
         :       }
  13    1:     INTEGER 18  //serial number
  16   13:     SEQUENCE {
  18    9:       OBJECT IDENTIFIER
         :         sha1withRSAEncryption (1 2 840 113549 1 1 5) //the certificate is signed with RSA and the SHA-1 hash algorithm
  29    0:       NULL
         :       }
  31   67:     SEQUENCE {
  33   19:       SET {
  35   17:         SEQUENCE {
  37   10:           OBJECT IDENTIFIER
         :             domainComponent (0 9 2342 19200300 100 1 25)
  49    3:           IA5String 'com' //issuer’s distinguished name-dc
         :           }
         :         }
  54   23:       SET {
  56   21:         SEQUENCE {
  58   10:           OBJECT IDENTIFIER
         :             domainComponent (0 9 2342 19200300 100 1 25)
  70    7:           IA5String 'example' //issuer’s distinguished name-dc
         :           }
         :         }
  79   19:       SET {
  81   17:         SEQUENCE {
  83    3:           OBJECT IDENTIFIER commonName (2 5 4 3)
  88   10:           PrintableString 'Example CA' //issuer’s distinguished name-cn
         :           }
         :         }
         :       }
 100   30:     SEQUENCE {
 102   13:       UTCTime 15/09/2004 11:48:21 GMT //not before
 117   13:       UTCTime 15/03/2005 11:48:21 GMT //not after
         :       }
 132   67:     SEQUENCE {
 134   19:       SET {
 136   17:         SEQUENCE {
 138   10:           OBJECT IDENTIFIER
         :             domainComponent (0 9 2342 19200300 100 1 25)
 150    3:           IA5String 'com' //the subject’s distinguished name-dc
         :           }
         :         }
 155   23:       SET {
 157   21:         SEQUENCE {
 159   10:           OBJECT IDENTIFIER
         :             domainComponent (0 9 2342 19200300 100 1 25)
 171    7:           IA5String 'example' //the subject’s distinguished name-dc
         :           }
         :         }
 180   19:       SET {
 182   17:         SEQUENCE {
 184    3:           OBJECT IDENTIFIER commonName (2 5 4 3)
 189   10:           PrintableString 'End Entity' //the subject’s distinguished name-cn
         :           }
         :         }
         :       }
 201  159:     SEQUENCE {
 204   13:       SEQUENCE {
 206    9:         OBJECT IDENTIFIER
         :           rsaEncryption (1 2 840 113549 1 1 1) //Use RSA as public key Algorithm
 217    0:         NULL
         :         }
 219  141:       BIT STRING, encapsulates {
 223  137:         SEQUENCE {
 226  129:           INTEGER //a 1024-bit RSA public key
         :             00 E1 6A E4 03 30 97 02 3C F4 10 F3 B5 1E 4D 7F
         :             14 7B F6 F5 D0 78 E9 A4 8A F0 A3 75 EC ED B6 56
         :             96 7F 88 99 85 9A F2 3E 68 77 87 EB 9E D1 9F C0
         :             B4 17 DC AB 89 23 A4 1D 7E 16 23 4C 4F A8 4D F5
         :             31 B8 7C AA E3 1A 49 09 F4 4B 26 DB 27 67 30 82
         :             12 01 4A E9 1A B6 C1 0C 53 8B 6C FC 2F 7A 43 EC
         :             33 36 7E 32 B2 7B D5 AA CF 01 14 C6 12 EC 13 F2
         :             2D 14 7A 8B 21 58 14 13 4C 46 A3 9A F2 16 95 FF
         :             23
 358    3:           INTEGER 65537
         :           }
         :         }
         :       }
 363  117:     [3] {
 365  115:       SEQUENCE {
 367   33:         SEQUENCE {
 369    3:           OBJECT IDENTIFIER subjectAltName (2 5 29 17) //the certificate includes one alternative name -- an electronic
                                                                  // mail address (rfc822Name)
 374   26:           OCTET STRING, encapsulates {
 376   24:             SEQUENCE {
 378   22:               [1] 'end.entity@example.com'
         :               }
         :             }
         :           }
 402   29:         SEQUENCE {
 404    3:           OBJECT IDENTIFIER subjectKeyIdentifier (2 5 29 14)
 409   22:           OCTET STRING, encapsulates {
 411   20:             OCTET STRING
         :               17 7B 92 30 FF 44 D6 66 E1 90 10 22 6C 16 4F C0
         :               8E 41 DD 6D
         :             }
         :           }
 433   31:         SEQUENCE {
 435    3:           OBJECT IDENTIFIER
         :             authorityKeyIdentifier (2 5 29 35)
 440   24:           OCTET STRING, encapsulates {
 442   22:             SEQUENCE {
 444   20:               [0]
         :                 08 68 AF 85 33 C8 39 4A 7A F8 82 93 8E 70 6A
         :                 4A 20 84 2C 32
         :               }
         :             }
         :           }
 466   14:         SEQUENCE {
 468    3:           OBJECT IDENTIFIER keyUsage (2 5 29 15) //
 473    1:           BOOLEAN TRUE
 476    4:           OCTET STRING, encapsulates {
 478    2:             BIT STRING 6 unused bits
         :               '11'B
         :             }
         :           }
         :         }
         :       }
         :     }
 482   13:   SEQUENCE {
 484    9:     OBJECT IDENTIFIER
         :         sha1withRSAEncryption (1 2 840 113549 1 1 5)  //Certificate Signature algoritm
 495    0:     NULL
         :     }
 497  129:   BIT STRING  //Certificate Signature
         :     00 20 28 34 5B 68 32 01 BB 0A 36 0E AD 71 C5 95
         :     1A E1 04 CF AE AD C7 62 14 A4 1B 36 31 C0 E2 0C
         :     3D D9 1E C0 00 DC 10 A0 BA 85 6F 41 CB 62 7A B7
         :     4C 63 81 26 5E D2 80 45 5E 33 E7 70 45 3B 39 3B
         :     26 4A 9C 3B F2 26 36 69 08 79 BB FB 96 43 77 4B
         :     61 8B A1 AB 91 64 E0 F3 37 61 3C 1A A3 A4 C9 8A
         :     B2 BF 73 D4 4D E4 58 E4 62 EA BC 20 74 92 86 0E
         :     CE 84 60 76 E9 73 BB C7 85 D3 91 45 EA 62 5D CD
         :   }

模块解释

1.TBSCertificate
TBSCertificate序列包括了证书的主体和issue的CA的信息,囊括了subject的名字和issuer,公钥,有效时间(起始时间和结束时间),版本号,序列号,可能有一些证书会包含可选择的唯一的识别域。剩下的部分描述了这些fields的格式和语义。一个TBSCertificate还通常会包含拓展部分。
1.1.Version
证书的Version由extension或者UniqueIdentifier决定。如果extensions被用到了,Version一定是3(值为2,从0开始算起),如果当前没有extensions,而有UniqueIdentifier,Version应该是2(值为1,从0开始算起),默认情况下,Version为1(值为0)。
1.2.Serial Number
Serial Number一定是CA分配给证书的一个正整数,而且必须是唯一的。(issuer name和serial number唯一的识别一个证书)serial number很可能是一个长整型的数,但不能超过20字节。
1.3.Signature
这个field包含了CA用来签名的算法的identifier,这里的值必须和signatureAlgorithm field in the sequence Certificate一样。
1.4.Issuer
Issuer field必须包含一个非空的唯一的名字(DN)。名字(Name)定义根据ASN.1结构:
Name ::= CHOICE { – only one possibility for now –
rdnSequence RDNSequence }

RDNSequence ::= SEQUENCE OF RelativeDistinguishedName

RelativeDistinguishedName ::=
SET SIZE (1..MAX) OF AttributeTypeAndValue

AttributeTypeAndValue ::= SEQUENCE {
type AttributeType,
value AttributeValue }

AttributeType ::= OBJECT IDENTIFIER

AttributeValue ::= ANY – DEFINED BY AttributeType

DirectoryString ::= CHOICE {
teletexString TeletexString (SIZE (1..MAX)),
printableString PrintableString (SIZE (1..MAX)),
universalString UniversalString (SIZE (1..MAX)),
utf8String UTF8String (SIZE (1..MAX)),
bmpString BMPString (SIZE (1..MAX)) }

Name是一个层次化的结构,是属性和属性值的组合,属性值由属性类型决定,属性类型一半是上文的DirectoryString。
1.5.Validity
Validity peroid是CA想管理和维护证书信息的时间段。这个field表示为证书有效开始的日期时间(not Before)和证书有效结束的日期时间(not after)两个日期的序列。not Before和not After都是以UTCTime或者GeneralizedTime来表示的,到2049年前用UTCTime,2050年及以后都是用GeneralizedTime表示。如果not After的时间是与设备的使用生命联系在一起的,not After的时间应该设置为99991231235959Z。
1.6.subject
Subject字段标识与存储在subject公钥字段的公钥联系在一起的实体。Subject的名字可能会出现在subject字段或者会出现在ubjectAltName extension。
1.7.Subject Public Key Info
Subject Public Key Info用来定义公钥和公钥使用的算法(比如RSA, DSA, or Diffie-Hellman)
1.8.Unique Identifiers
只有当版本为2或3时, 才能显示这些字段。证书中存在subject和颁发者唯一标识符
以此来处理主题或颁发者名称重用的可能性。此配置文件建议不重用名称,这样不同的实体和互联网证书就可以不使用唯一标识符。符合此配置文件的CAs不能生成具有唯一标识符的证书。此配置文件应能够分析包括唯一标识符的证书,但没有处理与唯一标识符关联的要求。

2.standard extension
2.1.Certificate Extensions
X.509 v3定义的证书在管理与CA的关系中为关联与用户或者公钥额外的属性提供了方法。X.509 v3证书格式同时也允许一些社区定义私有的拓展来携带一些信息。每个扩展在证书中被指定为关键或非关键。 如果证书使用的系统遇到它不识别的关键扩展或关键扩展包含无法处理的信息,那么它必须拒绝证书。如果非关键扩展不被识别, 则可以忽略它, 但如果它被识别, 则必须进行处理。社区可以选择使用额外的扩展;但是,在采用任何可能阻止在一般情况下使用的证书的关键扩展时, 应谨慎行事。

2.2.Authority Key Identifier
颁发机构密钥标识符(Authority Key Identifier)扩展提供了一种标识与用于签署证书的私钥相对应的公钥的方法。 如果颁发者具有多个签名密钥 (由于多个并发密钥对或由于转换而导致), 则使用此扩展。 标识可以基于密钥标识符 (颁发者证书中的主题密钥标识符或颁发者名称和序列号)。
Authority Key Identifier 扩展的 key Identifier 字段必须包含在符合 CA 生成的所有证书中, 以方便证书路径的构建。 有一个例外; 如果 CA 以 “自签名” 证书的形式分发其公钥, 则可以省略颁发机构密钥标识符。 自签名证书上的签名由与证书的subject公钥关联的私钥生成。 (这证明发行人同时拥有公钥和私钥。在这种情况下, subject和颁发机构密钥标识符是相同的, 但证书路径构建只需要subject密钥标识符。Key Identifier 字段的值应从用于验证证书签名的公钥或生成唯一值的方法派生。

2.3.Subject Key Identifier
Subject Key Identifier扩展提供了一种标识包含特定公钥的证书的方法。在具有一致性的CA证书中, Subject Key Identifier的值必须是该证书subject颁发的证书的Authority Key Identifier扩展的密钥标识符字段中的值。 在执行证书路径验证时, 不需要应用程序验证密钥标识符是否匹配。
subject key identifiers 字段的值应从用于验证证书签名的公钥或生成唯一值的方法派生。
两种从公钥中产生key identifiers的方法是:

  (1) The keyIdentifier is composed of the 160-bit SHA-1 hash of the
       value of the BIT STRING subjectPublicKey (excluding the tag,
       length, and number of unused bits).

  (2) The keyIdentifier is composed of a four-bit type field with
       the value 0100 followed by the least significant 60 bits of
       the SHA-1 hash of the value of the BIT STRING
       subjectPublicKey (excluding the tag, length, and number of
       unused bits).

其他合适的方法也是可以的。

应用

公钥的使用者需要有自信相关的私钥已经被正确的远程subject所拥有,在这个过程中加密和数字签名的机制都会被用到。这种自信来源于绑定到subjects公钥证书的公钥值。这种绑定是基于有一个可以信任的CA对每一个证书进行了数字签名。CA会借助技术手段(通过challenge-response protocol证明所属关系)、私钥的展示等方式为这种假设提供基础。证书的签名内容中限制了它的有效时间。因为证书的签名和有效时间能被一个证书使用的客户端独立地检查。证书能被能通过不被信任的通信渠道和服务器系统分配出去,而且能够缓存在证书使用系统的不安全的存储上。
一个需要知道公钥的安全服务的用户通常需要得到和验证一个包含公钥的证书。如果公钥的使用者没有已经持有一份为证书签名的CA的确定的公钥拷贝和CA的名称还有相关的信息(有效时间或者名字约束),那么它需要一份额外的证书来获得公钥。通常,这需要一连串的证书来保证一个公钥持有者的证书被一个CA签名,而且CAs可能会有更多的证书会被其他CAs签名。这些签名链叫做证书通路(certification paths)。
如果签名有效, 并且检查证书的软件信任颁发者, 则它可以使用该密钥与证书的subject进行安全的通信。

在X.509的系统里面,一个end system想要得到一个签名的证书需要通过一个证书签名请求(CSR)完成。

首先在创建CSR前,申请者会首先生成一对密钥,然后把私钥保密。CSR需要包含能够识别申请者的信息(比如一个distinguish name),这些信息是通过私钥加密的。CSR同时也要包含申请者挑选出来的公钥。CSR需要与其他的证书或者能证明身份的证明传送给CA。

一个组织的可信的根证书会被分配给所有的雇员以便让他们能使用公司的PKI系统。比如像Firefox,Safari这些浏览器会先预先安装一些根证书,所以主要CA的SSL证书会一直工作。浏览器的开发者也因此能了解哪些CA能为浏览器用户给予第三方信任。例如,Firefox提供一个CSV或者HTML文件包含了一个CA的列表。

X.509也包含一些对于证书撤回列表的标准实现,一个PKI系统经常忽略的方面。IETF同意的检查证书有效性的方法是在线的证书状态协议(OCSP)。Firefox 3能够缺省设置OCSP检测。

通常使用X.509证书的是基于HTTPS的网站。一个HTTPS网络服务器通过网络浏览器的认证后,浏览器用户会感觉它域该网站的交流是安全的和该网站是它所声称的那样。一个网站的运营者通过证书签名请求(CSR)向CA申请来得到证书。证书请求是一个包括网站名字、公司信息和公钥的电子文件。证书提供者在请求上签名来产生一个公共证书。在网站浏览的过程中,该公共证书向所有连接它的浏览器提供证书并向 web 浏览器证明证书提供者认为它已向该网站的所有者颁发了证书。

举个例子,当一个用户通过他们的浏览器连接到网站https://www.example.com/,如果浏览器没有给出任何证书警告信息,那么用户能够在理论上相信与https://www.example.com/交互等同于与在公共注册机构中列出的电子邮件地址”example.com”联系的实体交互, 即使该电子邮件地址可能不会显示在网站上的任何位置,同时没有其他任何担保人的暗示。此外, 证书的购买者、网站的运营者和网站内容的生成者之间的关系可能不可靠, 同时也无法保证。最好的情况是, 该证书保证了网站的唯一性, 前提是 web 站点本身没有受到破坏 (黑客) 或证书颁发过程被颠覆。
证书提供者可以选择颁发三种类型的证书, 每一个都需要其严格的审核程度。为了提高严格性 (自然地还有成本), 它们是: 域验证、组织验证和扩展验证。在 CA或者浏览器论坛中, 自愿参加者对这些苛刻的协议进行了粗略的讨论。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值