x509-cert: v1 CRLs fail to decode (`TBSCertList.version` is OPTIONAL)

Open Beginner friendly
#2,544 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
76/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
rust

Research direction

Start with TbsCertList in the x509-cert CRL module and compare its version field with the defaulted version in TbsCertificate; the issue says the prior fix in #2445 still applies. Add a round-trip test for a v1 CRL with the optional version absent, using the supplied DER reproducer. Done means the CRL decodes successfully and the test confirms its v1 representation.

Written by the indexing model from the issue text.

Description

RFC 5280 §5.1 makes TBSCertList.version OPTIONAL (absent means v1), and the doc
comment on TbsCertList quotes that, but the field is a required Version. So every
v1 CRL fails:

use der::Decode;
use x509_cert::crl::CertificateList;
// v1 CRL: TBSCertList { sha256WithRSAEncryption, CN=test, thisUpdate 260101000000Z }
let crl = hex_literal::hex!(
    "3044" "302f" "300d06092a864886f70d01010b0500"
    "300f310d300b06035504030c0474657374" "170d3236303130313030303030305a"
    "300d06092a864886f70d01010b0500" "03020000");
CertificateList::<x509_cert::certificate::Rfc5280>::from_der(&crl).unwrap();
// Err: unexpected ASN.1 DER tag: expected INTEGER, got SEQUENCE

I hit this on real CRLs (two Certipost qualified-CA CRLs and several in the EU DSS
test data); OpenSSL reads them as "Version 1".

#2445 had the fix (#[asn1(default = "Default::default")], as TbsCertificate
already does for its version, with a round-trip test) but was closed without review.
Its diff still applies to master 715d277d and makes the CRL above decode. Could it be
reopened?

Versions: x509-cert 0.3.0 and master 715d277d.


Found and analyzed with AI assistance; the reproducers and results above were run on the versions stated.

Dominant language
Rust
Stars
347
Forks
200
Avg merge
15h 53m
Merged PRs (30d)
34

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from RustCrypto/formats

All issues in RustCrypto/formats

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.