Skip to main content

TlsHandshake

Struct TlsHandshake 

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

One TLS handshake, driven by the caller: rustls’s own sans-IO connection.

A server records a refused, key-proven client as waiting under the source it was given, exactly as accept does. After finish the session is the finished [rustls::Connection], which keeps any application data that arrived with the last handshake bytes.

Implementations§

Source§

impl TlsHandshake

Source

pub fn client(config: Arc<ClientConfig>) -> Result<Self, PeerError>

A handshake as the dialing side, sending SERVER_NAME as the server name.

§Errors

PeerError::Tls when the connection cannot be created.

Source

pub fn client_named( config: Arc<ClientConfig>, name: ServerName<'static>, ) -> Result<Self, PeerError>

A handshake as the dialing side, sending name as the server name: the host dialled, for a server verified by Roots. [Established::peer] is the server’s leaf certificate’s fingerprint, however it was verified.

§Errors

PeerError::Tls when the connection cannot be created.

Source

pub fn server( config: Arc<ServerConfig>, source: Option<SocketAddr>, ) -> Result<Self, PeerError>

A handshake as the accepting side; source is where the peer connected from.

§Errors

PeerError::Tls when the connection cannot be created.

Source

pub fn local(self, local: SocketAddr) -> Self

This handshake knowing the local address the connection arrived at, which a policy’s access control list reads for rules that name a destination or a port. A server handshake without one refuses a connection such a rule would decide (Refusal::AddressUnknown).

Source

pub fn finish_unauthenticated( self, ) -> Result<(Connection, Option<PeerIdentity>), PeerError>

Finishes a completed handshake whose peer may have presented no certificate: the connection, and the peer’s verified certificate when it sent one.

A server built with ClientAuth::None asks for none, so its peer is always None and [Handshake::finish], which needs a peer, fails there. None means the client is not authenticated: the application must authenticate it inside the connection before trusting it. Drive the handshake with coqui_peer::complete_stream or complete_messages, then call this.

§Errors

PeerError::Tls when the handshake is not complete.

Trait Implementations§

Source§

impl Debug for TlsHandshake

Source§

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

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

impl Handshake for TlsHandshake

Source§

type Output = Connection

What a completed handshake yields besides the peer.
Source§

type Error = PeerError

Why the handshake failed. Never holds key material.
Source§

fn framing(&self) -> Framing

How this method divides what it sends.
Source§

fn receive(&mut self, input: &[u8]) -> Result<(), PeerError>

Gives the handshake what arrived from the peer: a chunk of the stream, or one message (see [Framing]). Read more
Source§

fn transmit(&mut self) -> Result<Option<Vec<u8>>, PeerError>

The next thing to send to the peer, or None when there is nothing to send until more input arrives. Call until None. Read more
Source§

fn is_complete(&self) -> bool

Whether the exchange is over and finish can be called; it succeeds when the method verified a peer. Output still waiting in transmit must be sent first.
Source§

fn finish(self) -> Result<Established<Connection>, PeerError>

The verified peer and the method’s output. Read more

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
§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

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<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.