#[non_exhaustive]pub struct TlsInfo { /* private fields */ }Expand description
TLS facts after the handshake, in fixed arrays.
let info = net_io::TlsInfo::new(Some("example.com"), Some(b"h2"), 0x0304, 0x1301).unwrap();
assert_eq!(info.sni(), Some("example.com"));
assert!(net_io::TlsInfo::new(Some(&"a".repeat(256)), None, 0, 0).is_none());
assert_eq!(info.peer_spki_sha256(), None);
let mutual = info.with_peer_spki_sha256([7; 32]);
assert_eq!(mutual.peer_spki_sha256(), Some(&[7; 32]));Implementations§
Source§impl TlsInfo
impl TlsInfo
Sourcepub fn new(
sni: Option<&str>,
alpn: Option<&[u8]>,
version: u16,
cipher_suite: u16,
) -> Option<TlsInfo>
pub fn new( sni: Option<&str>, alpn: Option<&[u8]>, version: u16, cipher_suite: u16, ) -> Option<TlsInfo>
Builds the facts; None if the SNI is longer than 255 bytes or the ALPN longer than 32.
Sourcepub fn cipher_suite(&self) -> u16
pub fn cipher_suite(&self) -> u16
The cipher suite code.
Sourcepub fn with_peer_spki_sha256(self, hash: [u8; 32]) -> TlsInfo
pub fn with_peer_spki_sha256(self, hash: [u8; 32]) -> TlsInfo
The facts with the SHA-256 of the client certificate’s public key
(its DER SubjectPublicKeyInfo). The engine sets it only for a client
certificate it verified (the chain, or a pin), never from unverified bytes.
Sourcepub fn peer_spki_sha256(&self) -> Option<&[u8; 32]>
pub fn peer_spki_sha256(&self) -> Option<&[u8; 32]>
The SHA-256 of the verified client certificate’s public key, for mapping a
mutual-TLS peer to a principal; None without a client certificate. It
stays the same when the certificate is reissued with the same key.
Trait Implementations§
Auto Trait Implementations§
impl Forget for TlsInfo
impl Freeze for TlsInfo
impl Move for TlsInfo
impl RefUnwindSafe for TlsInfo
impl Send for TlsInfo
impl Sync for TlsInfo
impl Unpin for TlsInfo
impl UnsafeUnpin for TlsInfo
impl UnwindSafe for TlsInfo
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more