You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When trying to load a private key and corresponding ECDSA client certificate I get an failed to parse private key as RSA, ECDSA, or EdDSA error from rustls, despite the key working fine with openssl.
After some digging it turns out it is because the private key file does not have the corresponding public key packed with it.
[1] publicKey. The RFC says it is optional, but we require it to be present.
The public part is not used for anything except to validate that it matches the public key derived from the private one, so I think this requirement could be relaxed.
use ring::signature::EcdsaKeyPair;
use ring::signature::ECDSA_P384_SHA384_ASN1_SIGNING;
use base64::prelude::*;
use ring::rand::SystemRandom;
fn main() {
let der = BASE64_STANDARD.decode("ME4CAQAwEAYHKoZIzj0CAQYFK4EEACIENzA1AgEBBDA6u5vLXwM2XYeoBzeYGVQAt7n5Vvjbtd2XDsQdk6ghFKZecMUL5h9lccg8Pwq+eqY=").unwrap();
let _key = EcdsaKeyPair::from_pkcs8(&ECDSA_P384_SHA384_ASN1_SIGNING, &der, &SystemRandom::new()).unwrap();
}
The text was updated successfully, but these errors were encountered:
PKCS8 encoded pem files have an option to have the public key in the
same file as the private key.
Not all pem files will have it, and the public key can be derived from
the private key anyway.
Fixesbriansmith#2133
PKCS8 encoded pem files have an option to have the public key in the
same file as the private key.
Not all pem files will have it, and the public key can be derived from
the private key anyway.
Fixesbriansmith#2133
I agree to license my contributions to each file under the terms given
at the top of each file I changed.
It seems fine to add the ability to parse PKCS#8 files missing the public key, I guess, but:
We should not change the implementation of the current API, which guarantees in its documentation that the pairwise consistency check is done. "The input must be in PKCS#8 v1 format. It must contain the public key in the ECPrivateKey structure; from_pkcs8() will verify that the public key and the private key are consistent with each other."
We should add a new API, and have test coverage analogous to the testing of the existing API.
EcdsaKeyPair::from_private_key_and_public_key needs an analogous counterpart.
When trying to load a private key and corresponding ECDSA client certificate I get an
failed to parse private key as RSA, ECDSA, or EdDSA
error from rustls, despite the key working fine with openssl.After some digging it turns out it is because the private key file does not have the corresponding public key packed with it.
https://lapo.it/asn1js/#ME4CAQAwEAYHKoZIzj0CAQYFK4EEACIENzA1AgEBBDA6u5vLXwM2XYeoBzeYGVQAt7n5Vvjbtd2XDsQdk6ghFKZecMUL5h9lccg8Pwq-eqY
There is a comment in suite_b.rs that says:
The public part is not used for anything except to validate that it matches the public key derived from the private one, so I think this requirement could be relaxed.
rust playground link with minimal setup for replication:
The text was updated successfully, but these errors were encountered: