diff --git a/quinn-proto/src/crypto.rs b/quinn-proto/src/crypto.rs index e8b7c04df..452e700a5 100644 --- a/quinn-proto/src/crypto.rs +++ b/quinn-proto/src/crypto.rs @@ -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; /// Type used to sign various values @@ -53,7 +51,7 @@ pub trait Session: Send + Sized { fn handshake_data(&self) -> Option>; /// Get the peer's identity, if available - fn peer_identity(&self) -> Option; + fn peer_identity(&self) -> Option>; /// Get the 0-RTT keys if available (clients only) /// diff --git a/quinn-proto/src/crypto/rustls.rs b/quinn-proto/src/crypto/rustls.rs index 724ba42e4..238c020c7 100644 --- a/quinn-proto/src/crypto/rustls.rs +++ b/quinn-proto/src/crypto/rustls.rs @@ -36,7 +36,6 @@ impl TlsSession { } impl crypto::Session for TlsSession { - type Identity = CertificateChain; type ClientConfig = Arc; type HmacKey = hmac::Key; type HandshakeTokenKey = hkdf::Prk; @@ -71,8 +70,10 @@ impl crypto::Session for TlsSession { })) } - fn peer_identity(&self) -> Option { - self.inner.peer_certificates().map(|v| v.to_vec().into()) + fn peer_identity(&self) -> Option> { + self.inner + .peer_certificates() + .map(|v| -> Box { Box::new(CertificateChain::from(v.to_vec())) }) } fn early_crypto(&self) -> Option<(Self::HeaderKey, Self::PacketKey)> { diff --git a/quinn/src/connection.rs b/quinn/src/connection.rs index 187e123a7..a7c441f3a 100644 --- a/quinn/src/connection.rs +++ b/quinn/src/connection.rs @@ -478,7 +478,11 @@ where } /// Cryptographic identity of the peer - pub fn peer_identity(&self) -> Option { + /// + /// 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> { self.0 .lock("peer_identity") .inner