Skip to content

Commit aa09034

Browse files
committed
Merge pull request #616 from hyperium/ssl-direct-streams
refactor(ssl): use openssl::DirectStreams
2 parents da817ba + 71db6a4 commit aa09034

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ version = "0.1"
2929
default-features = false
3030

3131
[dependencies.openssl]
32-
version = "0.6"
32+
version = "0.6.4"
3333
optional = true
3434

3535
[dependencies.solicit]

src/net.rs

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,20 @@ impl Write for HttpStream {
202202
}
203203
}
204204

205+
#[cfg(windows)]
206+
impl ::std::os::windows::io::AsRawSocket for HttpStream {
207+
fn as_raw_socket(&self) -> ::std::os::windows::io::RawSocket {
208+
self.0.as_raw_socket()
209+
}
210+
}
211+
212+
#[cfg(unix)]
213+
impl ::std::os::unix::io::AsRawFd for HttpStream {
214+
fn as_raw_fd(&self) -> i32 {
215+
self.0.as_raw_fd()
216+
}
217+
}
218+
205219
impl NetworkStream for HttpStream {
206220
#[inline]
207221
fn peer_addr(&mut self) -> io::Result<SocketAddr> {
@@ -439,16 +453,13 @@ mod openssl {
439453
type Stream = SslStream<HttpStream>;
440454

441455
fn wrap_client(&self, stream: HttpStream, host: &str) -> ::Result<Self::Stream> {
442-
//if let Some(ref verifier) = self.verifier {
443-
// verifier(&mut context);
444-
//}
445456
let ssl = try!(Ssl::new(&self.context));
446457
try!(ssl.set_hostname(host));
447-
SslStream::new_from(ssl, stream).map_err(From::from)
458+
SslStream::connect(ssl, stream).map_err(From::from)
448459
}
449460

450461
fn wrap_server(&self, stream: HttpStream) -> ::Result<Self::Stream> {
451-
match SslStream::new_server(&self.context, stream) {
462+
match SslStream::accept(&*self.context, stream) {
452463
Ok(ssl_stream) => Ok(ssl_stream),
453464
Err(SslIoError(e)) => {
454465
Err(io::Error::new(io::ErrorKind::ConnectionAborted, e).into())

0 commit comments

Comments
 (0)