forked from rust-postgres/rust-postgres
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathopenssl.rs
More file actions
26 lines (21 loc) · 634 Bytes
/
Copy pathopenssl.rs
File metadata and controls
26 lines (21 loc) · 634 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
extern crate openssl;
use std::error::Error;
use self::openssl::ssl::{SslContext, SslStream};
use io::{StreamWrapper, Stream, NegotiateSsl};
impl StreamWrapper for SslStream<Stream> {
fn get_ref(&self) -> &Stream {
self.get_ref()
}
fn get_mut(&mut self) -> &mut Stream {
self.get_mut()
}
}
impl NegotiateSsl for SslContext {
fn negotiate_ssl(&self,
_: &str,
stream: Stream)
-> Result<Box<StreamWrapper>, Box<Error + Send + Sync>> {
let stream = try!(SslStream::connect(self, stream));
Ok(Box::new(stream))
}
}