diff --git a/quinn-proto/src/crypto/types.rs b/quinn-proto/src/crypto/types.rs index 36c049767..4382b6ce9 100644 --- a/quinn-proto/src/crypto/types.rs +++ b/quinn-proto/src/crypto/types.rs @@ -52,6 +52,11 @@ impl CertificateChain { pub fn from_certs(certs: impl IntoIterator) -> Self { certs.into_iter().collect() } + + /// An iterator over the certificates in the chain + pub fn iter(&self) -> impl Iterator { + self.certs.iter() + } } impl std::iter::FromIterator for CertificateChain { @@ -71,6 +76,24 @@ impl From> for CertificateChain { } } +impl IntoIterator for CertificateChain { + type Item = rustls::Certificate; + type IntoIter = std::vec::IntoIter; + + fn into_iter(self) -> Self::IntoIter { + self.certs.into_iter() + } +} + +impl<'a> IntoIterator for &'a CertificateChain { + type Item = &'a rustls::Certificate; + type IntoIter = std::slice::Iter<'a, rustls::Certificate>; + + fn into_iter(self) -> Self::IntoIter { + self.certs.iter() + } +} + /// The private key of a TLS certificate to be used by a server #[derive(Debug, Clone)] pub struct PrivateKey {