1
0
mirror of https://github.com/actix/examples synced 2025-06-26 17:17:42 +02:00
This commit is contained in:
Rob Ede
2022-02-18 02:44:02 +00:00
parent aca1dab890
commit fbd3b228e9
48 changed files with 103 additions and 261 deletions

View File

@ -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()

View File

@ -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();

View File

@ -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};