Adding option to upgrade tcp connection to ssl connection
This commit is contained in:
parent
43f4737b85
commit
25633dee98
1 changed files with 13 additions and 0 deletions
|
|
@ -29,6 +29,19 @@ impl Client<TcpStream> {
|
|||
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<Client<SslStream<TcpStream>>> {
|
||||
// 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<SslStream<TcpStream>> {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue