forked from lavina/lavina
fix tls key parsing usage
This commit is contained in:
parent
70b12c9a0d
commit
c39928799d
|
@ -11,7 +11,7 @@ use futures_util::future::join_all;
|
|||
use prometheus::Registry as MetricsRegistry;
|
||||
use quick_xml::events::{BytesDecl, Event};
|
||||
use quick_xml::{NsReader, Writer};
|
||||
use rustls_pemfile::{certs, rsa_private_keys};
|
||||
use rustls_pemfile::{certs, read_one, Item as PemItem};
|
||||
use serde::Deserialize;
|
||||
use tokio::io::{AsyncBufRead, AsyncWrite, AsyncWriteExt, BufReader, BufWriter};
|
||||
use tokio::net::{TcpListener, TcpStream};
|
||||
|
@ -64,12 +64,14 @@ pub async fn launch(
|
|||
let certs = certs(&mut SyncBufReader::new(File::open(config.cert)?))?;
|
||||
let certs = certs.into_iter().map(Certificate).collect::<Vec<_>>();
|
||||
|
||||
let keys = rsa_private_keys(&mut SyncBufReader::new(File::open(config.key)?))?;
|
||||
let keys = keys.into_iter().map(PrivateKey).collect::<Vec<_>>();
|
||||
let key = match read_one(&mut SyncBufReader::new(File::open(config.key)?))? {
|
||||
Some(PemItem::ECKey(k) | PemItem::PKCS8Key(k) | PemItem::RSAKey(k)) => PrivateKey(k),
|
||||
_ => panic!("no keys in file"),
|
||||
};
|
||||
|
||||
let loaded_config = Arc::new(LoadedConfig {
|
||||
cert: certs.into_iter().next().expect("no certs in file"),
|
||||
key: keys.into_iter().next().expect("no keys in file"),
|
||||
key,
|
||||
});
|
||||
|
||||
let listener = TcpListener::bind(config.listen_on).await?;
|
||||
|
|
Loading…
Reference in New Issue