pub fn new_ssl_from_stream<A: ToSocketAddrsDomain>(
        socket_addrs: A,
        validate_domain: bool,
        stream: TcpStream,
    ) -> Result<Self, Error> {
        let mut builder =
            SslConnector::builder(SslMethod::tls()).map_err(Error::InvalidSslMethod)?;
        // TODO: support for certificate pinning
        if validate_domain {
            socket_addrs.domain().ok_or(Error::MissingDomain)?;
        } else {
            builder.set_verify(SslVerifyMode::NONE);
        }
        let connector = builder.build();

        let domain = socket_addrs.domain().unwrap_or("NONE").to_string();

        let stream = connector
            .connect(&domain, stream)
            .map_err(Error::SslHandshakeError)?;

        Ok(stream.into())
    }
/// Create a new SSL client using an existing TcpStream
Create a new SSL client using an existing TcpStream
Create a new SSL client using an existing TcpStream
pub fn new_ssl_from_stream<A: ToSocketAddrsDomain>(
        socket_addrs: A,
        validate_domain: bool,
        stream: TcpStream,
    ) -> Result<Self, Error> {
        let mut builder =
            SslConnector::builder(SslMethod::tls()).map_err(Error::InvalidSslMethod)?;
        // TODO: support for certificate pinning
        if validate_domain {
            socket_addrs.domain().ok_or(Error::MissingDomain)?;
        } else {
            builder.set_verify(SslVerifyMode::NONE);
        }
        let connector = builder.build();
        let domain = socket_addrs.domain().unwrap_or("NONE").to_string();
        let stream = connector
            .connect(&domain, stream)
            .map_err(Error::SslHandshakeError)?;
        Ok(stream.into())
    }
pub fn new_ssl_from_stream < A : ToSocketAddrsDomain > ( socket_addrs : A , validate_domain : bool , stream : TcpStream , ) -> Result < Self , Error > { let mut builder = SslConnector :: builder ( SslMethod :: tls ( ) ) . map_err ( Error :: InvalidSslMethod ) ? ; // TODO: support for certificate pinning if validate_domain { socket_addrs . domain ( ) . ok_or ( Error :: MissingDomain ) ? ; } else { builder . set_verify ( SslVerifyMode :: NONE ) ; } let connector = builder . build ( ) ; let domain = socket_addrs . domain ( ) . unwrap_or ( " " ) . to_string ( ) ; let stream = connector . connect ( & domain , stream ) . map_err ( Error :: SslHandshakeError ) ? ; Ok ( stream . into ( ) ) }
Create a new SSL client using an existing TcpStream
Create a new SSL client using an existing TcpStream
socket_addrs
A
validate_domain
bool
stream
TcpStream
socket_addrs
A
validate_domain
bool
stream
TcpStream