mirror of
https://github.com/actix/actix-web.git
synced 2024-12-17 05:36:36 +00:00
add x509 to stream extension (#844)
This commit is contained in:
parent
cc6e0c6d04
commit
6813ce789d
1 changed files with 12 additions and 0 deletions
|
@ -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
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue