Support pkcs8 private keys (allowing for ed25519 to be used for rpc)
This commit is contained in:
parent
30a7dee920
commit
fa394dcd27
@ -38,15 +38,16 @@ pub fn load_certs(filename: &str) -> Result<Vec<rustls::Certificate>, Error> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn load_private_key(filename: &str) -> Result<rustls::PrivateKey, Error> {
|
pub fn load_private_key(filename: &str) -> Result<rustls::PrivateKey, Error> {
|
||||||
let keyfile = fs::File::open(&filename)?;
|
let keydata = fs::read_to_string(filename)?;
|
||||||
let mut reader = io::BufReader::new(keyfile);
|
|
||||||
|
|
||||||
let keys = pemfile::rsa_private_keys(&mut reader).map_err(|_| {
|
let mut buf1 = keydata.as_bytes();
|
||||||
Error::Message(format!(
|
let rsa_keys = pemfile::rsa_private_keys(&mut buf1).unwrap_or_default();
|
||||||
"Could not decode private key from file: {}",
|
|
||||||
filename
|
let mut buf2 = keydata.as_bytes();
|
||||||
))
|
let pkcs8_keys = pemfile::pkcs8_private_keys(&mut buf2).unwrap_or_default();
|
||||||
})?;
|
|
||||||
|
let mut keys = rsa_keys;
|
||||||
|
keys.extend(pkcs8_keys.into_iter());
|
||||||
|
|
||||||
if keys.len() != 1 {
|
if keys.len() != 1 {
|
||||||
return Err(Error::Message(format!(
|
return Err(Error::Message(format!(
|
||||||
|
Loading…
Reference in New Issue
Block a user