rpki/specs/04_crl.md
2026-01-27 10:33:31 +08:00

142 lines
8.7 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 04. CRLResource Certificate Revocation List
## 4.1 对象定位
RPKI CA 必须发布符合 profile 的 CRL用于声明其签发且未过期证书中的撤销集合。RFC 6487 §5。
RFC 9829 更新了 RFC 6487 对 CRL Number 以及 “current CRL” 识别的处理规则。RFC 9829 §3。
## 4.2 原始载体与编码
- 载体X.509 CRL。
- 编码DER遵循 RFC 5280 的 CRL 结构与字段语义,但受 RPKI profile 限制。RFC 6487 §5“consistent with RFC 5280”
### 4.2.1 X.509 v2 CRL 基本语法ASN.1RFC 5280 §5.1
CRL 在编码层面是 RFC 5280 定义的 `CertificateList`DER。RFC 5280 §5.1。
```asn1
CertificateList ::= SEQUENCE {
tbsCertList TBSCertList,
signatureAlgorithm AlgorithmIdentifier,
signatureValue BIT STRING }
TBSCertList ::= SEQUENCE {
version Version OPTIONAL,
-- if present, MUST be v2
signature AlgorithmIdentifier,
issuer Name,
thisUpdate Time,
nextUpdate Time OPTIONAL,
revokedCertificates SEQUENCE OF SEQUENCE {
userCertificate CertificateSerialNumber,
revocationDate Time,
crlEntryExtensions Extensions OPTIONAL
-- if present, version MUST be v2
} OPTIONAL,
crlExtensions [0] EXPLICIT Extensions OPTIONAL
-- if present, version MUST be v2
}
```
> 注:`Version`/`Time`/`CertificateSerialNumber`/`Extensions` 的定义在 RFC 5280 §4.1`AlgorithmIdentifier` 的定义在 RFC 5280 §4.1.1.2RFC 5280 §5.1 的注释段落给出引用)。
### 4.2.2 CRL 扩展中常用内层结构ASN.1RFC 5280 §4.2.1.1RFC 5280 §5.2.3
RPKI profile经 RFC 9829 更新)要求 CRL **仅允许**两个扩展AKI 与 CRL Number。RFC 9829 §3.1。
```asn1
id-ce-authorityKeyIdentifier OBJECT IDENTIFIER ::= { id-ce 35 }
AuthorityKeyIdentifier ::= SEQUENCE {
keyIdentifier [0] KeyIdentifier OPTIONAL,
authorityCertIssuer [1] GeneralNames OPTIONAL,
authorityCertSerialNumber [2] CertificateSerialNumber OPTIONAL }
KeyIdentifier ::= OCTET STRING
id-ce-cRLNumber OBJECT IDENTIFIER ::= { id-ce 20 }
CRLNumber ::= INTEGER (0..MAX)
```
## 4.3 抽象数据模型(接口)
### 4.3.0 `Asn1TimeUtc`X.509 `Time` 的抽象)
X.509 中的 `Time` 是一个 CHOICE可用 `UTCTime``GeneralizedTime` 编码;但在语义层面都表达一个 UTC 时间点。RFC 5280 §4.1.2.5RFC 5280 §5.1.2.4。
因此在抽象模型中,将 `Time` 规范化为 “UTC 时间点 + 原始编码形态”:
| 字段 | 类型 | 语义 | 约束/解析规则 | RFC 引用 |
|---|---|---|---|---|
| `utc` | `UtcTime` | 规范化后的 UTC 时间点 | 从 `UTCTime`/`GeneralizedTime` 解码并转换为 UTC 时间点 | RFC 5280 §4.1.2.5.1RFC 5280 §4.1.2.5.2 |
| `encoding` | `enum{UTCTime, GeneralizedTime}` | 原始编码类型 | 需要保留编码形态以支持 profile 的编码约束校验 | RFC 5280 §5.1.2.4RFC 5280 §5.1.2.5 |
### 4.3.1 `RpkixCrl`
| 字段 | 类型 | 语义 | 约束/解析规则 | RFC 引用 |
|---|---|---|---|---|
| `raw_der` | `DerBytes` | CRL DER | 原样保留(建议) | RFC 6487 §5 |
| `version` | `int` | CRL 版本 | MUST 为 v2RP 不要求处理 v1 | RFC 6487 §5 |
| `issuer_dn` | `RpkixDistinguishedName` | CRL issuer | issuer DN 约束同证书 issuerCN/serialNumber 规则) | RFC 6487 §5引用 §4.4 |
| `signature_algorithm` | `Oid` | CRL 签名算法 | 必须为 `sha256WithRSAEncryption``1.2.840.113549.1.1.11` | RFC 6487 §5RFC 7935 §2引用 RFC 4055 |
| `this_update` | `Asn1TimeUtc` | 本次 CRL 生成时间 | X.509 `Time`UTCTime/GeneralizedTime解码为 UTC 时间点,并保留原始编码形态 | RFC 5280 §5.1.2.4RFC 5280 §4.1.2.5 |
| `next_update` | `Asn1TimeUtc` | 下次 CRL 计划时间 | **MUST present**(尽管 ASN.1 标注 OPTIONAL解码同 `this_update` | RFC 5280 §5.1.2.5 |
| `revoked_certs` | `list[RevokedCert]` | 撤销条目 | 仅包含未过期且已撤销证书 | RFC 6487 §5 |
| `extensions` | `CrlExtensions` | CRL 扩展 | **仅允许** AKI 与 CRL Number 两个扩展 | RFC 9829 §3.1(更新 RFC 6487 §5 |
### 4.3.2 `RevokedCert`
| 字段 | 类型 | 语义 | 约束/解析规则 | RFC 引用 |
|---|---|---|---|---|
| `serial_number` | `int` | 被撤销证书序列号 | 必须存在 | RFC 6487 §5 |
| `revocation_date` | `Asn1TimeUtc` | 撤销时间 | X.509 `Time` 解码为 UTC 时间点并保留原始编码形态revocationDate 的表达规则同 `thisUpdate` | RFC 6487 §5RFC 5280 §5.1.2.6(引用 §5.1.2.4 |
| `entry_extensions` | `None` | 条目扩展 | CRL entry extensions MUST NOT present | RFC 6487 §5 |
### 4.3.3 `CrlExtensions`
| 字段 | 类型 | 语义 | 约束/解析规则 | RFC 引用 |
|---|---|---|---|---|
| `authority_key_identifier` | `bytes` | AKI.keyIdentifier | **extnID=`2.5.29.35`**RP MUST 处理 AKICRL 扩展仅允许 AKI 与 CRLNumber | RFC 9829 §3.1RFC 5280 §5.2.1 |
| `crl_number` | `int` | CRLNumber | **extnID=`2.5.29.20`**RP 必须忽略其排序语义;仅检查 non-critical 且数值范围0..2^159-1 | RFC 9829 §3.1(引用 RFC 5280 §5.2.3 |
## 4.4 字段级约束清单(实现对照)
- CA 必须签发 version 2 CRLRP 不要求处理 v1。RFC 6487 §5。
- CRL 不得包含 Indirect CRL 或 Delta CRL。RFC 6487 §5。
- CRL 范围必须覆盖该 CA 签发的全部证书。RFC 6487 §5。
- `nextUpdate` MUST present尽管 ASN.1 标注 OPTIONAL。RFC 5280 §5.1.2.5。
- 时间编码规则(`thisUpdate`/`nextUpdate`/`revocationDate`2049及之前必须用 `UTCTime`2050及之后必须用 `GeneralizedTime`应用必须能处理两者。RFC 5280 §5.1.2.4RFC 5280 §5.1.2.5RFC 5280 §5.1.2.6(引用 §5.1.2.4)。
- 只允许两个 CRL 扩展AKI 与 CRLNumber除此之外不允许任何 CRL 扩展。RFC 9829 §3.1。
- RP 必须处理 AKICRLNumber 仅做 “non-critical + 数值范围” 检查并忽略其它语义。RFC 9829 §3.1。
- 每个撤销条目仅允许 Serial Number 与 Revocation Date不允许条目扩展。RFC 6487 §5。
## 4.5 CRL 验签与绑定校验(验证阶段)
> 本节描述“基于已解析的数据对象对 CRL 做签名校验cryptographic signature validation”所需输入与处理步骤。其定位属于验证阶段而非纯解码阶段
### 4.5.1 验签所需输入
- **CRL 对象本身**:包含 `tbsCertList`(待签名数据)、`signatureAlgorithm``signatureValue`。RFC 5280 §5.1。
- **CRL issuer 的 CA 证书(或其公钥)**:用于提供验签公钥(`SubjectPublicKeyInfo`。RFC 5280 §6.3.3 (f)-(g)。
- (链路上下文)用于验证 issuer CA 证书链的同一信任锚trust anchorCRL issuer 的证书链必须与目标证书使用同一信任锚。RFC 5280 §6.3.3 (f)。
### 4.5.2 绑定与一致性校验(推荐最小集合)
在执行签名验签之前RP 通常应进行下列绑定校验以确保“用的是正确的 issuer 证书/公钥”:
1. **Issuer DN 匹配**`CRL.issuer_dn` 必须等于 issuer CA 证书的 `subject`。RFC 5280 §5.1`issuer` 字段RFC 5280 §6.3.3 (b)“verify that the CRL issuer matches the certificate issuer” 的一般化要求)。
2. **AKI ↔ SKI 绑定**:若 issuer CA 证书包含 `SubjectKeyIdentifier`SKIOID `2.5.29.14`),则其值应与 CRL 的 `AuthorityKeyIdentifier.keyIdentifier`AKIOID `2.5.29.35`匹配。RFC 5280 §4.2.1.1RFC 5280 §4.2.1.2RFC 5280 §6.3.3 (c)(3)delta 与 complete CRL 的 AKI 匹配规则;在非 delta 场景下同样用于选择正确的签发者公钥)。
3. **KeyUsage 约束**:若 issuer CA 证书存在 `KeyUsage` 扩展OID `2.5.29.15`),则必须包含 `cRLSign` 位。RFC 5280 §4.2.1.3RFC 5280 §6.3.3 (f)。
> SKI 的生成算法在 RFC 5280 中不强制限定(不同 CA 可能采用不同方式生成 keyIdentifier因此一般做“字节值匹配”而不对 SKI 值做“从公钥推导再比对”的强校验。
### 4.5.3 签名验签
完成上述绑定后,使用 issuer CA 证书提供的公钥对 CRL 签名进行验签:
- 使用 issuer 的 `SubjectPublicKeyInfo` 验证 `signatureValue` 是对 `tbsCertList` 的正确签名。RFC 5280 §6.3.3 (g)。
- RPKI profile 限定签名算法为 `sha256WithRSAEncryption`OID `1.2.840.113549.1.1.11`),并要求算法参数编码符合 X.509/PKIX 约束(常见为 absent 或 NULL。RFC 6487 §5RFC 7935 §2RFC 5280 §4.1.1.2。