pub struct Builder { /* private fields */ }
Expand description

A builder type for TlsStreams.

Implementations§

source§

impl Builder

source

pub fn new() -> Builder

Returns a new Builder.

source

pub fn domain(&mut self, domain: &str) -> &mut Builder

Sets the domain associated with connections created with this Builder.

The domain will be used for Server Name Indication as well as certificate validation.

source

pub fn use_sni(&mut self, use_sni: bool) -> &mut Builder

Determines if Server Name Indication (SNI) will be used.

Defaults to true.

source

pub fn accept_invalid_hostnames( &mut self, accept_invalid_hostnames: bool ) -> &mut Builder

Determines if the server’s hostname will be checked during certificate verification.

Defaults to false.

source

pub fn verify_callback<F>(&mut self, callback: F) -> &mut Builderwhere F: Fn(CertValidationResult) -> Result<()> + 'static + Sync + Send,

Set a verification callback to be used for connections created with this Builder.

The callback is provided with an io::Result indicating if the (pre)validation was successful. The Ok() variant indicates a successful validation while the Err() variant contains the errorcode returned from the internal verification process. The validated certificate, is accessible through the second argument of the closure.

source

pub fn cert_store(&mut self, cert_store: CertStore) -> &mut Builder

Specifies a custom certificate store which is later used when validating a server’s certificate.

This option is only used for client connections and is used to construct the certificate chain which the server’s certificate is validated against.

Note that adding certificates here means that they are implicitly trusted.

source

pub fn request_application_protocols(&mut self, alpns: &[&[u8]]) -> &mut Builder

Requests one of a set of application protocols using alpn

source

pub fn connect<S>( &mut self, cred: SchannelCred, stream: S ) -> Result<TlsStream<S>, HandshakeError<S>>where S: Read + Write,

Initialize a new TLS session where the stream provided will be connecting to a remote TLS server.

If the stream provided is a blocking stream then the entire handshake will be performed if possible, but if the stream is in nonblocking mode then a HandshakeError::Interrupted variant may be returned. This type can then be extracted to later call MidHandshakeTlsStream::handshake when data becomes available.

source

pub fn accept<S>( &mut self, cred: SchannelCred, stream: S ) -> Result<TlsStream<S>, HandshakeError<S>>where S: Read + Write,

Initialize a new TLS session where the stream provided will be accepting a connection.

This method will tweak the protocol for “who talks first” and also currently disables validation of the client that’s connecting to us.

If the stream provided is a blocking stream then the entire handshake will be performed if possible, but if the stream is in nonblocking mode then a HandshakeError::Interrupted variant may be returned. This type can then be extracted to later call MidHandshakeTlsStream::handshake when data becomes available.

Trait Implementations§

source§

impl Default for Builder

source§

fn default() -> Builder

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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, U> TryFrom<U> for Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.