openai/codex · error · BuildCustomCaTransportError
Failed to parse certificate #
Error message
Failed to parse certificate #{certificate_index} from {} selected by {}: {source}. {hint} What it means
A single PEM block was parsed but could not be registered as a certificate with the reqwest client builder. This RegisterCertificate variant of BuildCustomCaTransportError fires per-certificate (the index identifies which block in the file failed), typically because the block is malformed or not a valid X.509 certificate even though it was delimited correctly.
Solutions
- Inspect the certificate at the reported index in the PEM file and remove or fix malformed blocks
- Regenerate the bundle from a trusted source so every CERTIFICATE block is valid X.509
- Check each block with `openssl x509 -noout -text -in <block>` to locate the bad certificate
- Fall back to system roots by unsetting the env var if the custom bundle is unnecessary
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at codex-rs/http-client/src/custom_ca.rs:102 when the library encounters an invalid state.
Common situations: See trigger scenarios.
Understand the failure class
- SSL/TLS and certificate errors — how TLS handshakes and certificate validation fail.
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
AI-assisted analysis of openai/codex@339751715c (2026-08-25).
Data as JSON: /api/errors/3b21f28339292211.
Report an issue: GitHub.
Appendix: source
Thrown at codex-rs/http-client/src/custom_ca.rs:102
path: PathBuf,
source: io::Error,
},
/// The selected CA file was readable, but did not produce usable certificate material.
#[error(
"Failed to load CA certificates from {} selected by {}: {detail}. {hint}",
path.display(),
source_env,
hint = CA_CERT_HINT
)]
InvalidCaFile {
source_env: &'static str,
path: PathBuf,
detail: String,
},
/// One parsed certificate block could not be registered with the reqwest client builder.
#[error(
"Failed to parse certificate #{certificate_index} from {} selected by {}: {source}. {hint}",
path.display(),
source_env,
hint = CA_CERT_HINT
)]
RegisterCertificate {
source_env: &'static str,
path: PathBuf,
certificate_index: usize,
source: reqwest::Error,
},
/// Reqwest rejected the final client configuration after a custom CA bundle was loaded.
#[error(
"Failed to build HTTP client while using CA bundle from {} ({}): {source}",
source_env,
path.display()
)]View on GitHub (pinned to 339751715c)