pub mod client;
pub mod server;
mod stream;
pub use stream::*;
use crate::utils::tls::WrappedX509;
use pingora_rustls::CertificateDer;
pub type CaType = [WrappedX509];
#[derive(Debug)]
pub struct TlsRef {
pub(super) peer_certs: Option<Vec<CertificateDer<'static>>>,
pub(super) cipher: Option<&'static str>,
pub(super) version: Option<&'static str>,
pub(super) server_name: Option<String>,
}
impl TlsRef {
pub fn peer_certificate_der(&self) -> Option<&[u8]> {
self.peer_certs
.as_ref()
.and_then(|certs| certs.first())
.map(|cert| cert.as_ref())
}
pub fn peer_cert_chain_der(&self) -> Option<&[CertificateDer<'static>]> {
self.peer_certs.as_deref()
}
pub fn current_cipher_name(&self) -> Option<&'static str> {
self.cipher
}
pub fn version(&self) -> Option<&'static str> {
self.version
}
pub fn server_name(&self) -> Option<&str> {
self.server_name.as_deref()
}
}