1
0
Fork 0
mirror of https://github.com/actix/actix-web.git synced 2024-12-17 13:46:36 +00:00

add x509 to stream extension (#844)

This commit is contained in:
Zeyi Fan 2019-05-15 08:38:59 -07:00 committed by Nikolay Kim
parent cc6e0c6d04
commit 6813ce789d

View file

@ -1,4 +1,5 @@
use std::net::{Shutdown, SocketAddr}; use std::net::{Shutdown, SocketAddr};
use std::rc::Rc;
use std::{io, time}; use std::{io, time};
use actix_net::ssl; use actix_net::ssl;
@ -6,6 +7,7 @@ use openssl::ssl::{AlpnError, SslAcceptor, SslAcceptorBuilder};
use tokio_io::{AsyncRead, AsyncWrite}; use tokio_io::{AsyncRead, AsyncWrite};
use tokio_openssl::SslStream; use tokio_openssl::SslStream;
use extensions::Extensions;
use server::{IoStream, ServerFlags}; use server::{IoStream, ServerFlags};
/// Support `SSL` connections via openssl package /// Support `SSL` connections via openssl package
@ -84,4 +86,14 @@ impl<T: IoStream> IoStream for SslStream<T> {
fn set_keepalive(&mut self, dur: Option<time::Duration>) -> io::Result<()> { fn set_keepalive(&mut self, dur: Option<time::Duration>) -> io::Result<()> {
self.get_mut().get_mut().set_keepalive(dur) self.get_mut().get_mut().set_keepalive(dur)
} }
fn extensions(&self) -> Option<Rc<Extensions>> {
if let Some(x509) = self.get_ref().ssl().peer_certificate() {
let mut extensions = Extensions::new();
extensions.insert(x509);
Some(Rc::new(extensions))
} else {
None
}
}
} }