Skip to main content

ServerConnection

Struct ServerConnection 

Source
pub struct ServerConnection { /* private fields */ }
Expand description

A QUIC server connection.

Implementations§

Source§

impl ServerConnection

Source

pub fn new( config: Arc<ServerConfig>, quic_version: Version, params: Vec<u8>, ) -> Result<Self, Error>

Make a new QUIC ServerConnection.

This differs from ServerConnection::new() in that it takes an extra params argument, which contains the TLS-encoded transport parameters to send.

Source

pub fn server_name(&self) -> Option<&DnsName<'_>>

Retrieves the server name, if any, used to select the certificate and private key.

This returns None until some time after the client’s server name indication (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 server name 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 server name is also used to match sessions during session resumption.

Source

pub fn set_resumption_data( &mut self, resumption_data: &[u8], ) -> Result<(), Error>

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 (otherwise an error will be returned).

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.

Source

pub fn received_resumption_data(&self) -> Option<&[u8]>

Retrieves the resumption data supplied by the client, if any.

Returns Some if and only if a valid resumption ticket has been received from the client.

Source

pub fn exporter(&mut self) -> Result<KeyingMaterialExporter, Error>

Returns an object that can derive key material from the agreed connection secrets.

See RFC5705 for more details on what this is for.

This function can be called at most once per connection.

This function will error:

  • if called prior to the handshake completing; (check with CommonState::is_handshaking first).
  • if called more than once per connection.

Methods from Deref<Target = ConnectionOutputs>§

Source

pub fn peer_identity(&self) -> Option<&Identity<'static>>

Retrieves the certificate chain or the raw public key used by the peer to authenticate.

This is made available for both full and resumed handshakes.

For clients, this is the identity of the server. For servers, this is the identity of the client, if client authentication was completed.

The return value is None until this value is available.

Source

pub fn alpn_protocol(&self) -> Option<&ApplicationProtocol<'static>>

Retrieves the protocol agreed with the peer via ALPN.

A return value of None after handshake completion means no protocol was agreed (because no protocols were offered or accepted by the peer).

Source

pub fn negotiated_cipher_suite(&self) -> Option<SupportedCipherSuite>

Retrieves the cipher suite agreed with the peer.

This returns None until the cipher suite is agreed.

Source

pub fn negotiated_key_exchange_group( &self, ) -> Option<&'static dyn SupportedKxGroup>

Retrieves the key exchange group agreed with the peer.

This function may return None depending on the state of the connection, the type of handshake, and the protocol version.

If CommonState::is_handshaking() is true this function will return None. Similarly, if the ConnectionOutputs::handshake_kind() is HandshakeKind::Resumed and the ConnectionOutputs::protocol_version() is TLS 1.2, then no key exchange will have occurred and this function will return None.

Source

pub fn protocol_version(&self) -> Option<ProtocolVersion>

Retrieves the protocol version agreed with the peer.

This returns None until the version is agreed.

Source

pub fn handshake_kind(&self) -> Option<HandshakeKind>

Which kind of handshake was performed.

This tells you whether the handshake was a resumption or not.

This will return None before it is known which sort of handshake occurred.

Trait Implementations§

Source§

impl Connection for ServerConnection

Source§

fn quic_transport_parameters(&self) -> Option<&[u8]>

Return the TLS-encoded transport parameters for the session’s peer. Read more
Source§

fn zero_rtt_keys(&self) -> Option<DirectionalKeys>

Compute the keys for encrypting/decrypting 0-RTT packets, if available
Source§

fn read_hs(&mut self, plaintext: &[u8]) -> Result<(), Error>

Consume unencrypted TLS handshake data. Read more
Source§

fn write_hs(&mut self, buf: &mut Vec<u8>) -> Option<KeyChange>

Emit unencrypted TLS handshake data. Read more
Source§

fn is_handshaking(&self) -> bool

Returns true if the connection is currently performing the TLS handshake.
Source§

impl Debug for ServerConnection

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Deref for ServerConnection

Source§

type Target = ConnectionOutputs

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl DerefMut for ServerConnection

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.