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.

Assessment

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

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.

Description

next-major-release

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.

Dominant language
Rust
Stars
42
Forks
55
Avg merge
3d 7h
Merged PRs (30d)
4

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

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.

More from rustls/pki-types

All issues in rustls/pki-types

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.