[][src]Struct schannel::tls_stream::Builder

pub struct Builder { /* fields omitted */ }

A builder type for TlsStreams.

Implementations

impl Builder[src]

pub fn new() -> Builder[src]

Returns a new Builder.

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

Sets the domain associated with connections created with this Builder.

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

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

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

Defaults to true.

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

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

Defaults to false.

pub fn verify_callback<F>(&mut self, callback: F) -> &mut Builder where
    F: Fn(CertValidationResult) -> Result<()> + 'static + Sync + Send
[src]

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.

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

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.

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

Requests one of a set of application protocols using alpn

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

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.

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

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

impl Default for Builder[src]

Auto Trait Implementations

impl !RefUnwindSafe for Builder

impl Send for Builder

impl Sync for Builder

impl Unpin for Builder

impl !UnwindSafe for Builder

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.