Problem creating self signed cert with ECDSA algorithm and using as client identity in native-tls
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 505
- Forks
- 157
- Avg merge
- 39m
- Merged PRs (30d)
- 1
Description
Hi everyone,
I am having trouble creating a self signed certificate with ECDSA that will be usable (on macOS) with native-tls as a client identity.
This is the code I have so far:
fn get_identity() -> Result<native_tls::Identity, String>
let mut dn = DistinguishedName::new();
dn.push(rcgen::DnType::OrganizationName, "Demo");
dn.push(rcgen::DnType::CountryName, "DE");
dn.push(rcgen::DnType::CommonName, "Demo");
let mut cert_params = CertificateParams::default();
cert_params.distinguished_name = dn;
cert_params.serial_number = Option::Some(1);
cert_params.alg = &rcgen::PKCS_ECDSA_P256_SHA256;
cert_params.is_ca = rcgen::IsCa::Ca(rcgen::BasicConstraints::Unconstrained);
let certificate = match Certificate::from_params(cert_params) {
Ok(certificate) => certificate,
Err(e) => return Err(e.to_string()),
};
let certificate = match Certificate::from_params(cert_params) {
Ok(certificate) => certificate,
Err(e) => return Err(e.to_string()),
};
let cert = match certificate.serialize_pem() {
Ok(cert) => cert,
Err(err) => return Err(format!("Error in serializing the cert pem: {}", err)),
};
let key = certificate.serialize_private_key_pem();
match native_tls::Identity::from_pkcs8(cert.as_bytes(), key.as_bytes()) {
Ok(identity) => return Ok(identity),
Err(err) => {
println!("Error in creating identity: {}", err);
},
};
}
The error I am getting from macOS security framework is:
Error in creating identity: Unknown format in import.
I got as far as identifying the issue being with the private key.
Is there anything I am doing completely wrong?
Thanks
Andreas
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 by reproducing the get_identity entry point on macOS and inspect the values passed to native_tls::Identity::from_pkcs8, along with the generated certificate and private-key PEM. No project file or test is named; done means establishing whether the generated ECDSA identity can be loaded as a native-tls client identity and documenting or fixing the failure.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- cryptography, security
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100