diff --git a/src/client.rs b/src/client.rs index 63858b9..24e857e 100644 --- a/src/client.rs +++ b/src/client.rs @@ -29,6 +29,19 @@ impl Client { Err(e) => Err(Error::Io(e)) } } + + /// This will upgrade a regular TCP connection to use SSL. + pub fn secure(mut self, ssl_context: SslContext) -> Result>> { + // TODO This needs to be tested + match self.run_command_and_check_ok("STARTTLS") { + Err(e) => return Err(e), + _ => {} + }; + match SslStream::connect(&ssl_context, self.stream) { + Ok(s) => Ok(Client::new(s)), + Err(e) => Err(Error::Ssl(e)) + } + } } impl Client> {