Skip to content

fix(tls): migrate off rustls-pemfile onto rustls-pki-types, drop RUSTSEC-2025-0134 ignore (task #66)#338

Merged
pilotspacex-byte merged 1 commit into
mainfrom
fix/t66-rustls-pki-types
Jul 15, 2026
Merged

fix(tls): migrate off rustls-pemfile onto rustls-pki-types, drop RUSTSEC-2025-0134 ignore (task #66)#338
pilotspacex-byte merged 1 commit into
mainfrom
fix/t66-rustls-pki-types

Conversation

@pilotspacex-byte

@pilotspacex-byte pilotspacex-byte commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Summary

Task #66: migrate off the unmaintained rustls-pemfile crate onto rustls-pki-types PEM parsing, and drop the RUSTSEC-2025-0134 ignore from the supply-chain gate.

What changed

  • src/tls.rs: certificate/key loading now uses CertificateDer::pem_file_iter / PrivateKeyDer::from_pem_file (covers server TLS init and the SIGHUP hot-reload path); error behavior stays fail-loud with equivalent diagnostics; parsing-seam tests added (cert chains, PKCS8/RSA/EC keys, garbage input).
  • Cargo.toml / Cargo.lock: rustls-pemfile removed from the dependency tree entirely.
  • deny.toml + .cargo/audit.toml: RUSTSEC-2025-0134 ignore removed — cargo deny check advisories and cargo audit pass without it.
  • .add/dependencies.allowlist, .github/dependabot.yml: dependency bookkeeping updated to match.

Verification

  • cargo fmt --check
  • cargo clippy -- -D warnings ✅ (default features)
  • cargo clippy --no-default-features --features runtime-tokio,jemalloc -- -D warnings
  • Targeted TLS tests green (load + SIGHUP reload + new parsing tests)
  • Supply-chain CI job re-verifies deny/audit on this PR

Summary by CodeRabbit

  • Changed
    • Updated TLS certificate, private key, and CA bundle parsing for improved security and compatibility.
    • Removed the legacy TLS PEM parsing component.
    • TLS configuration now reports clearer errors when certificate or key data is invalid.
    • Added validation for malformed certificate and key files.
    • Updated security checks and dependency configuration to reflect the TLS changes.

@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 07ea73d6-98a8-46c7-a1e9-1720800316e9

📥 Commits

Reviewing files that changed from the base of the PR and between 82b3bca and 2211cb0.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (7)
  • .add/dependencies.allowlist
  • .cargo/audit.toml
  • .github/dependabot.yml
  • CHANGELOG.md
  • Cargo.toml
  • deny.toml
  • src/tls.rs

📝 Walkthrough

Walkthrough

The TLS configuration now parses certificates, private keys, and CA bundles with rustls-pki-types. Dependency features, allowlists, Dependabot patterns, advisory ignores, changelog entries, and invalid-PEM tests were updated accordingly.

Changes

TLS PKI migration

Layer / File(s) Summary
Dependency and security configuration
.add/dependencies.allowlist, .cargo/audit.toml, .github/dependabot.yml, Cargo.toml, deny.toml
Replaces rustls-pemfile with optional rustls-pki-types, updates runtime feature wiring and dependency grouping, and removes the related advisory ignore entry.
TLS parsing and failure validation
src/tls.rs, CHANGELOG.md
Uses CertificateDer and PrivateKeyDer PEM readers for TLS and mTLS configuration, with InvalidData parse errors and tests for corrupted certificate and key PEM input.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Suggested reviewers: tindang97

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/t66-rustls-pki-types

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

…es (task #66)

rustls-pemfile 2.2.0 is unmaintained (RUSTSEC-2025-0134) with no safe drop-in
upgrade in the 2.x line. It was ignore-listed in deny.toml/.cargo/audit.toml
when the supply-chain CI gate was wired up (#326) specifically because the
real fix required touching src/tls.rs, out of scope for that CI-wiring PR.
This closes that follow-up.

build_tls_config (src/tls.rs) now parses PEM directly via rustls-pki-types'
PemObject trait, already present transitively through rustls's own
pki_types re-export: CertificateDer::pem_reader_iter for cert chains (server
cert + optional CA chain for mTLS) and PrivateKeyDer::from_pem_reader for
the private key. rustls-pki-types is promoted to a direct optional
dependency (features = ["std"], needed for the reader-based PemObject
methods) gated behind the same runtime-tokio/runtime-monoio feature flags
rustls-pemfile used. No behavior change: same fail-loud io::Error wrapping
per stage (TLS cert file/parse, TLS key file/parse, CA cert parse), same
SIGHUP hot-reload path (src/tls.rs spawn_sighup_reload_thread), same
cipher-suite allowlist and mTLS client-verifier logic — untouched.

Test coverage gap found during migration: the existing suite only exercised
missing-file paths (NotFound), never a genuine DER/PEM decode failure — the
exact seam this migration touches. Added two tests exercising well-formed-
PEM-markers-but-corrupt-body input directly against the new parser:
test_build_tls_config_garbage_cert_parse_error and
test_build_tls_config_garbage_key_parse_error, both asserting the expected
"TLS cert parse" / "TLS key parse" error context survives the migration.
All 11 tls:: tests pass (including the two openssl-backed real-cert reload
tests, unchanged).

rustls-pemfile is fully removed from Cargo.toml/Cargo.lock. The
RUSTSEC-2025-0134 ignore entries are removed from deny.toml and
.cargo/audit.toml; `cargo deny check advisories licenses bans sources`
(0.19.6) and `cargo audit` (0.22.2) both pass clean against the resulting
lockfile with no ignore needed for this advisory. Also updated
.add/dependencies.allowlist and .github/dependabot.yml's crypto-tls group
to reflect the dependency swap.

Verified: cargo fmt --check; cargo clippy -- -D warnings (default
features); cargo clippy --no-default-features --features
runtime-tokio,jemalloc -- -D warnings; cargo test --lib tls:: (11/11
passed, both feature sets); cargo deny check advisories licenses bans
sources; cargo audit.

task: #66
author: Tin Dang <tindang.ht97@gmail.com>
@TinDang97
TinDang97 force-pushed the fix/t66-rustls-pki-types branch from 257de50 to 2211cb0 Compare July 15, 2026 16:21
@pilotspacex-byte
pilotspacex-byte merged commit c98d230 into main Jul 15, 2026
8 of 10 checks passed
@pilotspacex-byte
pilotspacex-byte deleted the fix/t66-rustls-pki-types branch July 15, 2026 16:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants