mirror of
https://github.com/actix/examples
synced 2025-06-26 17:17:42 +02:00
chore: upgrade to rustls v0.23
This commit is contained in:
@ -5,10 +5,10 @@ edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
actix-web.workspace = true
|
||||
awc = { workspace = true, features = ["rustls-0_21"] }
|
||||
awc = { workspace = true, features = ["rustls-0_23"] }
|
||||
|
||||
env_logger.workspace = true
|
||||
log.workspace = true
|
||||
mime = "0.3"
|
||||
rustls.workspace = true
|
||||
webpki-roots = "0.25"
|
||||
webpki-roots = "0.26"
|
||||
|
@ -2,7 +2,7 @@ use std::{sync::Arc, time::Instant};
|
||||
|
||||
use actix_web::{get, middleware, web::Data, App, HttpResponse, HttpServer};
|
||||
use awc::{http::header, Client, Connector};
|
||||
use rustls::{ClientConfig, OwnedTrustAnchor, RootCertStore};
|
||||
use rustls::{ClientConfig, RootCertStore};
|
||||
|
||||
const MAP_URL: &str =
|
||||
"https://upload.wikimedia.org/wikipedia/commons/f/ff/Pizigani_1367_Chart_10MB.jpg";
|
||||
@ -49,7 +49,7 @@ async fn main() -> std::io::Result<()> {
|
||||
// Wikipedia requires a User-Agent header to make requests
|
||||
.add_default_header((header::USER_AGENT, "awc-example/1.0"))
|
||||
// a "connector" wraps the stream into an encrypted connection
|
||||
.connector(Connector::new().rustls_021(Arc::clone(&client_tls_config)))
|
||||
.connector(Connector::new().rustls_0_23(Arc::clone(&client_tls_config)))
|
||||
.finish();
|
||||
|
||||
App::new()
|
||||
@ -65,17 +65,13 @@ async fn main() -> std::io::Result<()> {
|
||||
|
||||
/// Create simple rustls client config from root certificates.
|
||||
fn rustls_config() -> ClientConfig {
|
||||
let mut root_store = RootCertStore::empty();
|
||||
root_store.add_trust_anchors(webpki_roots::TLS_SERVER_ROOTS.iter().map(|ta| {
|
||||
OwnedTrustAnchor::from_subject_spki_name_constraints(
|
||||
ta.subject,
|
||||
ta.spki,
|
||||
ta.name_constraints,
|
||||
)
|
||||
}));
|
||||
rustls::crypto::aws_lc_rs::default_provider()
|
||||
.install_default()
|
||||
.unwrap();
|
||||
|
||||
let root_store = RootCertStore::from_iter(webpki_roots::TLS_SERVER_ROOTS.to_owned());
|
||||
|
||||
rustls::ClientConfig::builder()
|
||||
.with_safe_defaults()
|
||||
.with_root_certificates(root_store)
|
||||
.with_no_client_auth()
|
||||
}
|
||||
|
Reference in New Issue
Block a user