Tweak ChannelBinding API
This commit is contained in:
parent
a2cac0ef61
commit
d9d81b53a3
@ -60,11 +60,11 @@ where
|
|||||||
|
|
||||||
fn poll(&mut self) -> Poll<(TlsStream<S>, ChannelBinding), native_tls::Error> {
|
fn poll(&mut self) -> Poll<(TlsStream<S>, ChannelBinding), native_tls::Error> {
|
||||||
let stream = try_ready!(self.0.poll());
|
let stream = try_ready!(self.0.poll());
|
||||||
let mut channel_binding = ChannelBinding::new();
|
|
||||||
|
|
||||||
if let Some(buf) = stream.get_ref().tls_server_end_point().unwrap_or(None) {
|
let channel_binding = match stream.get_ref().tls_server_end_point().unwrap_or(None) {
|
||||||
channel_binding = channel_binding.tls_server_end_point(buf);
|
Some(buf) => ChannelBinding::tls_server_end_point(buf),
|
||||||
}
|
None => ChannelBinding::none(),
|
||||||
|
};
|
||||||
|
|
||||||
Ok(Async::Ready((stream, channel_binding)))
|
Ok(Async::Ready((stream, channel_binding)))
|
||||||
}
|
}
|
||||||
|
@ -60,10 +60,10 @@ where
|
|||||||
fn poll(&mut self) -> Poll<(SslStream<S>, ChannelBinding), HandshakeError<S>> {
|
fn poll(&mut self) -> Poll<(SslStream<S>, ChannelBinding), HandshakeError<S>> {
|
||||||
let stream = try_ready!(self.0.poll());
|
let stream = try_ready!(self.0.poll());
|
||||||
|
|
||||||
let mut channel_binding = ChannelBinding::new();
|
let channel_binding = match tls_server_end_point(stream.get_ref().ssl()) {
|
||||||
if let Some(buf) = tls_server_end_point(stream.get_ref().ssl()) {
|
Some(buf) => ChannelBinding::tls_server_end_point(buf),
|
||||||
channel_binding = channel_binding.tls_server_end_point(buf);
|
None => ChannelBinding::none(),
|
||||||
}
|
};
|
||||||
|
|
||||||
Ok(Async::Ready((stream, channel_binding)))
|
Ok(Async::Ready((stream, channel_binding)))
|
||||||
}
|
}
|
||||||
|
@ -12,15 +12,16 @@ pub struct ChannelBinding {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl ChannelBinding {
|
impl ChannelBinding {
|
||||||
pub fn new() -> ChannelBinding {
|
pub fn none() -> ChannelBinding {
|
||||||
ChannelBinding {
|
ChannelBinding {
|
||||||
tls_server_end_point: None,
|
tls_server_end_point: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn tls_server_end_point(mut self, tls_server_end_point: Vec<u8>) -> ChannelBinding {
|
pub fn tls_server_end_point(tls_server_end_point: Vec<u8>) -> ChannelBinding {
|
||||||
self.tls_server_end_point = Some(tls_server_end_point);
|
ChannelBinding {
|
||||||
self
|
tls_server_end_point: Some(tls_server_end_point),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,7 +61,7 @@ where
|
|||||||
fn handle_tls(self, use_tls: bool, stream: S) -> FutureResult<(S, ChannelBinding), Void> {
|
fn handle_tls(self, use_tls: bool, stream: S) -> FutureResult<(S, ChannelBinding), Void> {
|
||||||
debug_assert!(!use_tls);
|
debug_assert!(!use_tls);
|
||||||
|
|
||||||
future::ok((stream, ChannelBinding::new()))
|
future::ok((stream, ChannelBinding::none()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -113,7 +114,7 @@ where
|
|||||||
}
|
}
|
||||||
PreferTlsFutureInner::Raw(s) => Ok(Async::Ready((
|
PreferTlsFutureInner::Raw(s) => Ok(Async::Ready((
|
||||||
MaybeTlsStream::Raw(s.take().expect("future polled after completion")),
|
MaybeTlsStream::Raw(s.take().expect("future polled after completion")),
|
||||||
ChannelBinding::new(),
|
ChannelBinding::none(),
|
||||||
))),
|
))),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user