RustCrypto / RustCrypto/formats
x509-cert: How to use dynamic signer with Builder?
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 338
- Forks
- 188
- Avg merge
- 4d 6h
- Merged PRs (30d)
- 15
Description
Hey 👋🏻
I'm trying to use a dynamic signer when using RequestBuilder, but I'm running into this:
the size for values of type
dyn Signer<_>cannot be known at compilation time
the traitSizedis not implemented fordyn Signer<_>
Here's a distillation of what I'm attempting:
use p256::pkcs8::LineEnding;
use rand_core::OsRng;
use std::error::Error;
use std::str::FromStr;
use x509_cert::{builder::RequestBuilder, name::Name};
fn main() -> Result<(), Box<dyn Error>> {
let req_signer: Box<dyn p256::ecdsa::signature::Signer<_>>;
if true {
req_signer = Box::new(p256::ecdsa::SigningKey::random(&mut OsRng));
} else {
req_signer = Box::new(p384::ecdsa::SigningKey::random(&mut OsRng));
}
let subject = Name::from_str("CN=Test")?;
let csr_builder = RequestBuilder::new(subject, req_signer.as_ref())?; // <--- Error
let csr = csr_builder.build::<p256::ecdsa::DerSignature>()?; // <--- p256 or p384 would need to be used here
let csr_pem = csr.to_pem(LineEnding::LF)?;
println!("{}", csr_pem);
Ok(())
}
Does that make sense? Am I just making a stupid mistake, or approaching this in the wrong way?
Thanks for any help!
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the RequestBuilder::new and build::<...> entry points shown in the issue, then inspect their signer and signature-type requirements. The payload names no files or tests. Done means establishing and documenting a supported dynamic-signer approach, or clearly confirming the API limitation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- cryptography
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100