Use custom rustls and alpn fedichatv0

Maybe this fixes a bug I'm looking at? Not sure though. It should make
the protocol more robust though
This commit is contained in:
2026-06-01 14:28:21 -07:00
parent bcfd328c04
commit 0fc73f1c85
3 changed files with 91 additions and 5 deletions
+31 -5
View File
@@ -12,6 +12,7 @@ use diesel_async::pooled_connection::AsyncDieselConnectionManager;
use diesel_async::pooled_connection::deadpool::Pool;
use quinn::rustls::pki_types::{PrivateKeyDer,CertificateDer,pem::PemObject};
use quinn::Endpoint;
use quinn::crypto::rustls::QuicServerConfig;
use std::io;
use std::fs;
use std::net::{IpAddr,SocketAddr};
@@ -22,7 +23,6 @@ use serde::{Deserialize,Serialize};
use tracing::{error,instrument,warn,debug,info,Level};
use tokio::sync::{RwLock,broadcast,mpsc};
use crate::config::Config;
use crate::state::{State,StateError};
@@ -147,17 +147,43 @@ async fn main() -> ExitCode {
};
let quinn_config = match quinn::ServerConfig::with_single_cert(certs, key){
Ok(val) => val,
let server_crypto = match rustls::ServerConfig::builder()
.with_no_client_auth()
.with_single_cert(certs, key)
{
Ok(mut val) => {
val.alpn_protocols = vec![b"fedichatv0".to_vec()];
match QuicServerConfig::try_from(val) {
Ok(conf) => conf,
Err(e) => {
error!("Unable to intialize TLS server configuration: {}",e);
return ExitCode::FAILURE;
}
}
},
Err(e) => {
error!("Unable to intialize quinn server configuration: {:?}",e);
error!("Unable to intialize TLS server configuration: {}",e);
return ExitCode::FAILURE;
}
};
let server_config =
quinn::ServerConfig::with_crypto(Arc::new(server_crypto));
//let quinn_config = match quinn::ServerConfig::with_single_cert(certs, key){
// Ok(val) => val,
// Err(e) => {
// error!("Unable to intialize quinn server configuration: {:?}",e);
// return ExitCode::FAILURE;
// }
//};
// Bind this endpoint to a UDP socket on the given server address.
let endpoint = match Endpoint::server(
quinn_config,
server_config,
SocketAddr::new(address,config.port)
) {
Ok(val) => val,