Open
Description
How to reproduce
Test certificates
Working certificates (-sha256 option)
openssl req -x509 \
-sha256 -days 356 \
-nodes \
-newkey rsa:4096 \
-subj "/CN=example.com" \
-keyout rootCA.key -out rootCA.crt
Failing certificates (-sha512 option)
openssl req -x509 \
-sha512 -days 356 \
-nodes \
-newkey rsa:4096 \
-subj "/CN=example.com" \
-keyout rootCA.key -out rootCA.crt
Code
use std::fs::read_to_string;
fn main() {
let private_key = read_to_string("rootCA.key").unwrap();
let private_key = rcgen::KeyPair::from_pem(&private_key).unwrap();
println!("KeyPair alg: {:?}", private_key.algorithm());
let cert = read_to_string("rootCA.crt").unwrap();
let params = rcgen::CertificateParams::from_ca_cert_pem(&cert, private_key).unwrap();
println!("Params alg: {:?}", params.alg);
if let Err(e) = rcgen::Certificate::from_params(params) {
println!("Error: {:#}", e);
} else {
println!("All good :-)")
};
}
Test results
If using the -sha256
certificate files, the output is:
KeyPair alg: PKCS_RSA_SHA256
Params alg: PKCS_RSA_SHA256
All good :-)
If using the -sha512
certificate files, the output is:
KeyPair alg: PKCS_RSA_SHA256
Params alg: PKCS_RSA_SHA512
Error: The provided certificate's signature algorithm is incompatible with the given key pair
Is this expected?
Metadata
Metadata
Assignees
Labels
No labels
Activity