Fix benches & example

This commit is contained in:
asonix 2024-05-19 10:04:36 -05:00
parent 6ef255e2f4
commit 8bf8d0f781
3 changed files with 8 additions and 3 deletions

View file

@ -18,6 +18,7 @@ rustls = { version = "0.23", default-features = false }
[dev-dependencies]
actix-web = { version = "4.6.0", features = ["rustls-0_23"] }
criterion = "0.5"
rustls = "0.23"
rustls-pemfile = "2.0.0"
tokio = { version = "1.35.1", features = ["fs"] }

View file

@ -22,7 +22,7 @@ fn prepare_key() -> CertifiedKey {
let mut reader = BufReader::new(keyfile);
let private_key = rustls_pemfile::private_key(&mut reader).unwrap().unwrap();
let private_key = rustls::crypto::ring::sign::any_supported_type(&private_key).unwrap();
let private_key = rustls::crypto::aws_lc_rs::sign::any_supported_type(&private_key).unwrap();
CertifiedKey::new(certs, private_key)
}

View file

@ -8,6 +8,10 @@ async fn index() -> &'static str {
#[actix_web::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
rustls::crypto::aws_lc_rs::default_provider()
.install_default()
.expect("Set provider");
let initial_key = read_key().await?.unwrap();
let (tx, rx) = rustls_channel_resolver::channel::<32>(initial_key);
@ -33,7 +37,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
.with_cert_resolver(rx);
HttpServer::new(|| App::new().route("/", web::get().to(index)))
.bind_rustls_0_22("0.0.0.0:8443", server_config)?
.bind_rustls_0_23("0.0.0.0:8443", server_config)?
.bind("0.0.0.0:8080")?
.run()
.await?;
@ -52,7 +56,7 @@ async fn read_key() -> Result<Option<rustls::sign::CertifiedKey>, Box<dyn std::e
return Ok(None);
};
let private_key = rustls::crypto::ring::sign::any_supported_type(&private_key)?;
let private_key = rustls::crypto::aws_lc_rs::sign::any_supported_type(&private_key)?;
Ok(Some(rustls::sign::CertifiedKey::new(certs, private_key)))
}