use hudsucker::{ certificate_authority::RcgenAuthority, rcgen::{CertificateParams, KeyPair}, rustls::crypto::aws_lc_rs, *, }; use std::net::SocketAddr; use tracing::*; async fn shutdown_signal() { tokio::signal::ctrl_c() .await .expect("Failed to install CTRL+C signal handler"); } #[tokio::main] async fn main() { tracing_subscriber::fmt::init(); let key_pair = include_str!("ca/hudsucker.key"); let ca_cert = include_str!("ca/hudsucker.cer"); let key_pair = KeyPair::from_pem(key_pair).expect("Failed to parse private key"); let ca_cert = CertificateParams::from_ca_cert_pem(ca_cert) .expect("Failed to parse CA certificate") .self_signed(&key_pair) .expect("Failed to sign CA certificate"); let ca = RcgenAuthority::new(key_pair, ca_cert, 1_000, aws_lc_rs::default_provider()); let proxy = Proxy::builder() .with_addr(SocketAddr::from(([127, 0, 0, 1], 3000))) .with_ca(ca) .with_rustls_client(aws_lc_rs::default_provider()) .with_graceful_shutdown(shutdown_signal()) .build() .expect("Failed to create proxy"); if let Err(e) = proxy.start().await { error!("{}", e); } }