Erase crypto::Session::Identity

This commit is contained in:
Benjamin Saunders
2021-10-10 14:10:20 -07:00
parent a384ee2edb
commit 6fa5a007ec
3 changed files with 10 additions and 7 deletions
+1 -3
View File
@@ -29,8 +29,6 @@ pub(crate) mod types;
/// A cryptographic session (commonly TLS)
pub trait Session: Send + Sized {
/// Cryptographic identity of the peer
type Identity: Sized;
/// Type used to hold configuration for client sessions
type ClientConfig: ClientConfig<Self>;
/// Type used to sign various values
@@ -53,7 +51,7 @@ pub trait Session: Send + Sized {
fn handshake_data(&self) -> Option<Box<dyn Any>>;
/// Get the peer's identity, if available
fn peer_identity(&self) -> Option<Self::Identity>;
fn peer_identity(&self) -> Option<Box<dyn Any>>;
/// Get the 0-RTT keys if available (clients only)
///
+4 -3
View File
@@ -36,7 +36,6 @@ impl TlsSession {
}
impl crypto::Session for TlsSession {
type Identity = CertificateChain;
type ClientConfig = Arc<rustls::ClientConfig>;
type HmacKey = hmac::Key;
type HandshakeTokenKey = hkdf::Prk;
@@ -71,8 +70,10 @@ impl crypto::Session for TlsSession {
}))
}
fn peer_identity(&self) -> Option<CertificateChain> {
self.inner.peer_certificates().map(|v| v.to_vec().into())
fn peer_identity(&self) -> Option<Box<dyn Any>> {
self.inner
.peer_certificates()
.map(|v| -> Box<dyn Any> { Box::new(CertificateChain::from(v.to_vec())) })
}
fn early_crypto(&self) -> Option<(Self::HeaderKey, Self::PacketKey)> {
+5 -1
View File
@@ -478,7 +478,11 @@ where
}
/// Cryptographic identity of the peer
pub fn peer_identity(&self) -> Option<S::Identity> {
///
/// The dynamic type returned is determined by the configured
/// [`Session`](proto::crypto::Session). For the default `rustls` session, the return value can
/// be [`downcast`](Box::downcast) to a [`CertificateChain`](crate::CertificateChain).
pub fn peer_identity(&self) -> Option<Box<dyn Any>> {
self.0
.lock("peer_identity")
.inner