chore(deps): migrate off unmaintained rustls-pemfile (RUSTSEC-2025-0134)#7
Merged
StefanSteiner merged 1 commit intoMay 18, 2026
Conversation
The `rustls-pemfile` crate is archived upstream — its README confirms the API will not be extended, and RustSec issued RUSTSEC-2025-0134 marking the crate as unmaintained. The functionality has moved into `rustls-pki-types::pem`, which `rustls` already re-exports as `rustls::pki_types`. This commit replaces every call site in `hyperdb-api-core` with the `PemObject` trait from `rustls::pki_types::pem`: * `hyperdb-api-core/src/client/tls.rs` — three call sites in `rustls_impl::create_connector`. CA-cert and client-cert loading now use `CertificateDer::pem_file_iter`, and the client private key uses `PrivateKeyDer::from_pem_file`. The new API opens and buffers the file internally, so the `BufReader` plumbing and the explicit `File::open` step go away. The "no private key found" branch also goes away — `from_pem_file` returns `Error::NoItemsFound` directly when the file is syntactically valid PEM but contains no key section. * `hyperdb-api-core/tests/tls_tests.rs` — three call sites in `start_echo_server`. The tests parse PEM from in-memory `&str` buffers, so they now use `pem_slice_iter` / `from_pem_slice`. The `rustls-pemfile` workspace dependency is dropped from the root `Cargo.toml` and from `hyperdb-api-core/Cargo.toml`; no new dep is added because `rustls::pki_types` is already in our direct dependency graph via `rustls 0.23`. The corresponding waivers for RUSTSEC-2025-0134 are removed from `deny.toml` and `.cargo/audit.toml`. Verified: `cargo fmt --all --check`, `cargo clippy --workspace --all-targets --all-features -- -D warnings`, the full TLS integration suite (`cargo test -p hyperdb-api-core --test tls_tests`, 15/15 passing), the workspace test gate, the `hyperdb-bootstrap` test gate, `cargo deny check` (now clean without the waiver), and `cargo audit --deny warnings`. Lockfile confirms `rustls-pemfile` is fully gone.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Migrate off unmaintained
rustls-pemfileSummary
The
rustls-pemfilecrate is archived upstream — its README confirms the API will not be extended, and RustSec issued RUSTSEC-2025-0134 marking the crate as unmaintained. The functionality has moved intorustls-pki-types::pem, whichrustlsalready re-exports asrustls::pki_types.This PR replaces every call site in
hyperdb-api-corewith thePemObjecttrait fromrustls::pki_types::pem, drops the workspace dependency, and removes the corresponding waiver fromdeny.tomland.cargo/audit.toml. It is a single atomic commit (c08ecf7).What changed
Production code:
hyperdb-api-core/src/client/tls.rsThree call sites in
rustls_impl::create_connector:File::open+BufReader+rustls_pemfile::certs(...)CertificateDer::pem_file_iter(ca_path)CertificateDer::pem_file_iter(cert_path)File::open+BufReader+rustls_pemfile::private_key(...)?.ok_or_else(\"no private key found\")PrivateKeyDer::from_pem_file(key_path)The new API opens and buffers the file internally, so the explicit
File::open+BufReaderplumbing falls away. The "no private key found" branch also goes away —from_pem_filereturnsError::NoItemsFounddirectly when the file is syntactically valid PEM but contains no key section, which is the same outcome the old code synthesized via.ok_or_else(...).Net change in
tls.rs: −21 lines, error coverage preserved.Tests:
hyperdb-api-core/tests/tls_tests.rsThree call sites in
start_echo_serverparse PEM from in-memory&strbuffers, so they migrate topem_slice_iter/from_pem_slicerather than the file-based variants. The previousrustls_pemfile::private_key(...).unwrap().unwrap()(double-unwrap ofResult<Option<PrivateKeyDer>, io::Error>) collapses to a single.unwrap()becausePrivateKeyDer::from_pem_slicereturnsResult<PrivateKeyDer, Error>—NoItemsFoundis now a variant of the error enum rather than aNonecase.Dependency graph
Cargo.toml:rustls-pemfile = \"2.0\".hyperdb-api-core/Cargo.toml:rustls-pemfile = { workspace = true }.rustls::pki_typesis already in our direct graph viarustls = \"0.23\"(which re-exportsrustls-pki-types1.14.1, the same crate that owns the new PEM-parsing API). Thepemmodule is gated behind theallocfeature (default-on), already enabled by our existingfeatures = [\"std\", \"ring\", \"tls12\"].grep -c rustls-pemfile Cargo.lockreturns0post-merge.Waivers
RUSTSEC-2025-0134removed from bothdeny.tomland.cargo/audit.toml. This was the only entry whose underlying issue was "upstream is dead, must migrate." The remaining waivers (RUSTSEC-2024-0436forpaste,RUSTSEC-2023-0071forrsa) and the forward-looking thrift CVE note are unchanged.Docs
DEVELOPMENT.mdhad two stale references torustls-pemfilein the dependency tables (lines 273 and 856 pre-PR). Both updated to reflect that PEM parsing now comes throughrustls's re-exportedpki_types::pem.Why this is safe
rustls-pki-typeswas already pulled byrustls,rcgen,tokio-rustls, andreqwest. We just stop reaching for the unmaintained sibling crate.rustls-pemfile 2.2.0's implementation was already a thin wrapper overrustls-pki-types::pem— the upstream maintainers folded it back into pki-types and archived the wrapper. Behavior is byte-for-byte equivalent.rustls_tests::*cases that exercise both the migrated production paths (CA loading, mTLS) and the migrated test helper.Verification
All gates run locally:
cargo fmt --all --checkcargo clippy --workspace --all-targets --all-features -- -D warningscargo test -p hyperdb-api-core --test tls_tests— 15/15 passcargo test --workspace --exclude hyperdb-api-node --exclude hyperdb-bootstrap(withHYPERD_PATH) — full workspace greencargo test -p hyperdb-bootstrap— greencargo deny check— clean (advisories ok, bans ok, licenses ok, sources ok) without the dropped waivercargo audit --deny warnings— cleangrep -c rustls-pemfile Cargo.lock—0Test plan
ubuntu-latest/macos-14/windows-latest) green on this PR.auditjob stays clean — confirms RustSec advisory-db doesn't re-flag anything we removed the waiver for.hyperdb-api-coreneed code changes — the public API surface (TlsConfig,rustls_impl::create_connector) is unchanged; only internal parsing implementation moved.Out of scope
paste,rsaMarvin Attack, the forward-looking thrift CVE note) — preserved as-is per the rationale already documented indeny.toml/.cargo/audit.toml. Each requires a separate upstream resolution and is tracked independently.