rustls / rustls/rustls-platform-verifier

Could we cache `rustls-native-certs::load_native_certs()`?

Open
#230 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
158
Forks
60
Avg merge
5d 10h
Merged PRs (30d)
3

Description

When creating a new verifier, on certain OSs, rustls_native_certs::load_native_certs is called, which is documented to be potentially expensive, since it probes for certificates, and loads each file.
Would it be possible to cache the result (static LazyLock), and ideally expose a function to initialize the cache?

https://github.com/rustls/rustls-platform-verifier/blob/996b1c903491641b17b3c9afb65d1352f6fc6b76/rustls-platform-verifier/src/verification/others.rs#L92

/// ## Caveats
///
/// This function can be expensive: on some platforms it involves loading
/// and parsing a ~300KB disk file. It's therefore prudent to call
/// this sparingly.

https://github.com/rustls/rustls-native-certs/blob/559fd3d8390da90865693e3b48ae6eef56c4d111/src/lib.rs#L118

Contributor guide

No contributing guide indexed for this repository

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.

Research direction

Start in rustls-platform-verifier/src/verification/others.rs at the referenced call to rustls_native_certs::load_native_certs(), then read how new verifiers reach it. Determine how the result can be cached and how an initialization function should be exposed. Done means repeated verifier creation reuses the cached result and the requested initializer is available.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
security
Issue type
Refactor
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.