#6146·k6

AIA: add PKCS#7 parser support for intermediate fetching

Author: vtorosyanCreated Jul 14, 2026Updated Sep 22, 2026
Labelstriage

Context

Follow-up to #6137 (opt-in AIA certificate chain fetching).

The current AIA fetcher in lib/netext/aia.go handles intermediate certificates served as raw DER or PEM. Some public CAs — notably Sectigo, and older Verisign chains — serve their intermediates as PKCS#7 / CMS bundles (Content-Type: application/pkcs7-mime, extension .p7c). Those responses parse as neither DER nor PEM and are silently dropped, leaving the chain incomplete.

Current behaviour

Since #6137 landed, when an AIA response looks like PKCS#7 (by Content-Type or by ASN.1 signedData OID heuristic), we emit a Warn log so users can diagnose "AIA didn't work" for these chains. The intermediate is still not consumed.

What's needed

Add a PKCS#7 fallback after the DER/PEM attempts in fetchCertFromAIAURL:

  1. If DER parse fails
  2. If PEM decode fails
  3. New: Try PKCS#7 parse — extract certificate(s) from the CMS bundle and use them

Implementation notes

  • Go's standard library does not include PKCS#7. A third-party dep is required — go.mozilla.org/pkcs7 (or github.com/mozilla-services/pkcs7) is the common choice.
  • Adding a dep needs a maintainer decision per Dependencies.md.
  • Alternative: hand-roll a minimal ASN.1 parser for the signedData certificate set. More code but no dep.

Acceptance criteria

  • PKCS#7 AIA responses parse successfully and the extracted intermediate is used for chain verification
  • Cache still deduplicates fetches (currently keyed by URL)
  • Existing tests still pass
  • New test covers PKCS#7 happy path (real .p7c bundle → chain completes)

Related