mirror of
https://github.com/actix/examples
synced 2025-06-26 17:17:42 +02:00
fmt
This commit is contained in:
@ -66,15 +66,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_server_trust_anchors(webpki_roots::TLS_SERVER_ROOTS.0.iter().map(
|
||||
|ta| {
|
||||
OwnedTrustAnchor::from_subject_spki_name_constraints(
|
||||
ta.subject,
|
||||
ta.spki,
|
||||
ta.name_constraints,
|
||||
)
|
||||
},
|
||||
));
|
||||
root_store.add_server_trust_anchors(webpki_roots::TLS_SERVER_ROOTS.0.iter().map(|ta| {
|
||||
OwnedTrustAnchor::from_subject_spki_name_constraints(
|
||||
ta.subject,
|
||||
ta.spki,
|
||||
ta.name_constraints,
|
||||
)
|
||||
}));
|
||||
|
||||
rustls::ClientConfig::builder()
|
||||
.with_safe_defaults()
|
||||
|
@ -10,10 +10,7 @@ use openssl::{
|
||||
x509::X509,
|
||||
};
|
||||
|
||||
pub async fn gen_tls_cert(
|
||||
user_email: &str,
|
||||
user_domain: &str,
|
||||
) -> anyhow::Result<Certificate> {
|
||||
pub async fn gen_tls_cert(user_email: &str, user_domain: &str) -> anyhow::Result<Certificate> {
|
||||
// Create acme-challenge dir.
|
||||
fs::create_dir("./acme-challenge").unwrap();
|
||||
|
||||
|
@ -5,13 +5,11 @@ use std::{any::Any, env, fs::File, io::BufReader, net::SocketAddr};
|
||||
|
||||
use actix_tls::accept::rustls::{reexports::ServerConfig, TlsStream};
|
||||
use actix_web::{
|
||||
dev::Extensions, rt::net::TcpStream, web, App, HttpRequest, HttpResponse,
|
||||
HttpServer, Responder,
|
||||
dev::Extensions, rt::net::TcpStream, web, App, HttpRequest, HttpResponse, HttpServer, Responder,
|
||||
};
|
||||
use log::info;
|
||||
use rustls::{
|
||||
server::AllowAnyAnonymousOrAuthenticatedClient, Certificate, PrivateKey,
|
||||
RootCertStore,
|
||||
server::AllowAnyAnonymousOrAuthenticatedClient, Certificate, PrivateKey, RootCertStore,
|
||||
};
|
||||
use rustls_pemfile::{certs, pkcs8_private_keys};
|
||||
|
||||
|
Reference in New Issue
Block a user