Skip to content

Commit 92dbfc6

Browse files
claudedjc
authored andcommitted
Tie lifetime of valid_dns_names/valid_uri_names to struct lifetime
Return &'a str instead of &str to explicitly tie the lifetime of the returned string references to the 'a lifetime of the Cert struct, since the strings are derived from the certificate data.
1 parent 2c46166 commit 92dbfc6

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/cert.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ impl<'a> Cert<'a> {
149149
/// [EndEntityCert::verify_is_valid_for_subject_name].
150150
///
151151
/// [EndEntityCert::verify_is_valid_for_subject_name]: crate::EndEntityCert::verify_is_valid_for_subject_name
152-
pub fn valid_dns_names(&self) -> impl Iterator<Item = &str> {
152+
pub fn valid_dns_names(&self) -> impl Iterator<Item = &'a str> {
153153
NameIterator::new(self.subject_alt_name).filter_map(|result| {
154154
let presented_id = match result.ok()? {
155155
GeneralName::DnsName(presented) => presented,
@@ -175,7 +175,7 @@ impl<'a> Cert<'a> {
175175
///
176176
/// This function returns URIs as strings without performing validation beyond checking that
177177
/// they are valid UTF-8.
178-
pub fn valid_uri_names(&self) -> impl Iterator<Item = &str> {
178+
pub fn valid_uri_names(&self) -> impl Iterator<Item = &'a str> {
179179
NameIterator::new(self.subject_alt_name).filter_map(|result| {
180180
let presented_id = match result.ok()? {
181181
GeneralName::UniformResourceIdentifier(presented) => presented,

0 commit comments

Comments
 (0)