Struct rustls::ServerSession [−][src]
This represents a single TLS server session.
Send TLS-protected data to the peer using the io::Write
trait implementation.
Read data from the peer using the io::Read
trait implementation.
Implementations
impl ServerSession
[src]
pub fn new(config: &Arc<ServerConfig>) -> ServerSessionⓘNotable traits for ServerSession
impl Read for ServerSessionimpl Write for ServerSession
[src]
Notable traits for ServerSession
impl Read for ServerSessionimpl Write for ServerSession
Make a new ServerSession. config
controls how
we behave in the TLS protocol.
pub fn get_sni_hostname(&self) -> Option<&str>
[src]
Retrieves the SNI hostname, if any, used to select the certificate and private key.
This returns None
until some time after the client’s SNI extension
value is processed during the handshake. It will never be None
when
the connection is ready to send or process application data, unless the
client does not support SNI.
This is useful for application protocols that need to enforce that the
SNI hostname matches an application layer protocol hostname. For
example, HTTP/1.1 servers commonly expect the Host:
header field of
every request on a connection to match the hostname in the SNI extension
when the client provides the SNI extension.
The SNI hostname is also used to match sessions during session resumption.
pub fn received_resumption_data(&self) -> Option<&[u8]>
[src]
Application-controlled portion of the resumption ticket supplied by the client, if any.
Recovered from the prior session’s set_resumption_data
. Integrity is guaranteed by rustls.
Returns Some
iff a valid resumption ticket has been received from the client.
pub fn set_resumption_data(&mut self, data: &[u8])
[src]
Set the resumption data to embed in future resumption tickets supplied to the client.
Defaults to the empty byte string. Must be less than 2^15 bytes to allow room for other
data. Should be called while is_handshaking
returns true to ensure all transmitted
resumption tickets are affected.
Integrity will be assured by rustls, but the data will be visible to the client. If secrecy from the client is desired, encrypt the data separately.
pub fn reject_early_data(&mut self)
[src]
Explicitly discard early data, notifying the client
Useful if invariants encoded in received_resumption_data()
cannot be respected.
Must be called while is_handshaking
is true.
Trait Implementations
impl Debug for ServerSession
[src]
impl Read for ServerSession
[src]
fn read(&mut self, buf: &mut [u8]) -> Result<usize>
[src]
Obtain plaintext data received from the peer over this TLS connection.
If the peer closes the TLS session cleanly, this fails with an error of kind ErrorKind::ConnectionAborted once all the pending data has been read. No further data can be received on that connection, so the underlying TCP connection should closed too.
Note that support close notify varies in peer TLS libraries: many do not support it and uncleanly close the TCP connection (this might be vulnerable to truncation attacks depending on the application protocol). This means applications using rustls must both handle ErrorKind::ConnectionAborted from this function, and unexpected closure of the underlying TCP connection.
pub fn read_vectored(
&mut self,
bufs: &mut [IoSliceMut<'_>]
) -> Result<usize, Error>
1.36.0[src]
&mut self,
bufs: &mut [IoSliceMut<'_>]
) -> Result<usize, Error>
pub fn is_read_vectored(&self) -> bool
[src]
pub unsafe fn initializer(&self) -> Initializer
[src]
pub fn read_to_end(&mut self, buf: &mut Vec<u8, Global>) -> Result<usize, Error>
1.0.0[src]
pub fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
1.0.0[src]
pub fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
1.6.0[src]
pub fn by_ref(&mut self) -> &mut Self
1.0.0[src]
pub fn bytes(self) -> Bytes<Self>
1.0.0[src]
pub fn chain<R>(self, next: R) -> Chain<Self, R> where
R: Read,
1.0.0[src]
R: Read,
pub fn take(self, limit: u64) -> Take<Self>
1.0.0[src]
impl Session for ServerSession
[src]
fn read_tls(&mut self, rd: &mut dyn Read) -> Result<usize>
[src]
fn write_tls(&mut self, wr: &mut dyn Write) -> Result<usize>
[src]
Writes TLS messages to wr
.
fn process_new_packets(&mut self) -> Result<(), TLSError>
[src]
fn wants_read(&self) -> bool
[src]
fn wants_write(&self) -> bool
[src]
fn is_handshaking(&self) -> bool
[src]
fn set_buffer_limit(&mut self, len: usize)
[src]
fn send_close_notify(&mut self)
[src]
fn get_peer_certificates(&self) -> Option<Vec<Certificate>>
[src]
fn get_alpn_protocol(&self) -> Option<&[u8]>
[src]
fn get_protocol_version(&self) -> Option<ProtocolVersion>
[src]
fn export_keying_material(
&self,
output: &mut [u8],
label: &[u8],
context: Option<&[u8]>
) -> Result<(), TLSError>
[src]
&self,
output: &mut [u8],
label: &[u8],
context: Option<&[u8]>
) -> Result<(), TLSError>
fn get_negotiated_ciphersuite(&self) -> Option<&'static SupportedCipherSuite>
[src]
fn complete_io<T>(&mut self, io: &mut T) -> Result<(usize, usize), Error> where
Self: Sized,
T: Read + Write,
[src]
Self: Sized,
T: Read + Write,
impl Write for ServerSession
[src]
fn write(&mut self, buf: &[u8]) -> Result<usize>
[src]
Send the plaintext buf
to the peer, encrypting
and authenticating it. Once this function succeeds
you should call write_tls
which will output the
corresponding TLS records.
This function buffers plaintext sent before the TLS handshake completes, and sends it as soon as it can. This buffer is of unlimited size so writing much data before it can be sent will cause excess memory usage.
fn write_vectored(&mut self, bufs: &[IoSlice<'_>]) -> Result<usize>
[src]
fn flush(&mut self) -> Result<()>
[src]
pub fn is_write_vectored(&self) -> bool
[src]
pub fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
1.0.0[src]
pub fn write_all_vectored(
&mut self,
bufs: &mut [IoSlice<'_>]
) -> Result<(), Error>
[src]
&mut self,
bufs: &mut [IoSlice<'_>]
) -> Result<(), Error>
pub fn write_fmt(&mut self, fmt: Arguments<'_>) -> Result<(), Error>
1.0.0[src]
pub fn by_ref(&mut self) -> &mut Self
1.0.0[src]
Auto Trait Implementations
impl !RefUnwindSafe for ServerSession
impl Send for ServerSession
impl Sync for ServerSession
impl Unpin for ServerSession
impl !UnwindSafe for ServerSession
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,