pub struct DtlsSession { /* private fields */ }Expand description
An established DTLS session for a CoAP/EST-coaps connection.
RFC 9483 §5: EST-coaps uses DTLS to secure the CoAP transport. DTLS 1.2 (RFC 6347) and DTLS 1.3 (RFC 9147) are supported.
This struct tracks the session state needed for EST operations: the peer identity (from the client certificate or PSK), the session identifier for resumption, and protocol version.
Implementations§
Source§impl DtlsSession
impl DtlsSession
Sourcepub fn new(
session_id: Vec<u8>,
peer_addr: SocketAddr,
protocol_version: DtlsVersion,
) -> Self
pub fn new( session_id: Vec<u8>, peer_addr: SocketAddr, protocol_version: DtlsVersion, ) -> Self
Creates a new DTLS session record.
Sourcepub fn with_client_cert(
session_id: Vec<u8>,
peer_addr: SocketAddr,
protocol_version: DtlsVersion,
client_cert_der: Vec<u8>,
) -> Self
pub fn with_client_cert( session_id: Vec<u8>, peer_addr: SocketAddr, protocol_version: DtlsVersion, client_cert_der: Vec<u8>, ) -> Self
Creates a new DTLS session with a client certificate.
Sourcepub fn session_id(&self) -> &[u8] ⓘ
pub fn session_id(&self) -> &[u8] ⓘ
Returns the opaque session identifier.
Sourcepub fn peer_addr(&self) -> SocketAddr
pub fn peer_addr(&self) -> SocketAddr
Returns the peer network address.
Sourcepub fn client_cert(&self) -> Option<&[u8]>
pub fn client_cert(&self) -> Option<&[u8]>
Returns the DER-encoded client certificate, if presented.
Sourcepub fn created_at(&self) -> Instant
pub fn created_at(&self) -> Instant
Returns when the session was established.
Sourcepub fn protocol_version(&self) -> DtlsVersion
pub fn protocol_version(&self) -> DtlsVersion
Returns the negotiated DTLS version.
Sourcepub fn is_expired(&self, ttl: Duration) -> bool
pub fn is_expired(&self, ttl: Duration) -> bool
Checks whether the session has exceeded the given TTL.
Sourcepub fn client_cert_info(&self) -> Option<ClientCertInfo>
pub fn client_cert_info(&self) -> Option<ClientCertInfo>
Extracts client certificate information from this session.
Returns None if no client certificate was presented or if the
certificate cannot be parsed.
Trait Implementations§
Source§impl Clone for DtlsSession
impl Clone for DtlsSession
Source§fn clone(&self) -> DtlsSession
fn clone(&self) -> DtlsSession
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more