rustls / rustls/pki-types

Error return type of TryFrom<Vec<u8>> for PrivateKeyDer<'_> doesn't impl std::error::Error

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

Nobody has claimed this yet.

next-major-release
Dominant language
Rust
Stars
39
Forks
51
PR merge metrics
No merged PRs in 30d

Description

I tried the following:

    let key = PrivateKeyDer::try_from(std::fs::read(key)?)?;

And I get the error:

? couldn't convert the error: str: std::error::Error is not satisfied
the question mark operation (?) implicitly performs a conversion on the error value using the From trait
required for &str to implement std::error::Error
required for anyhow::Error to implement From<&str>

Unfortunately &str doesn't impl core::error::Error, so using it as the error return type in a try_from can cause users of the library some difficulty. It would be better to instead return a type that impls core::error::Error in the error value.

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

Search for the TryFrom<Vec> implementation for PrivateKeyDer<'_> and inspect its current error return type. Update the conversion so its error implements core::error::Error, then verify that the anyhow example in the issue can use ? without a conversion error.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
cryptography
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.