Skip to content

Commit c4d5b19

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 b712306 commit c4d5b19

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
@@ -169,7 +169,7 @@ impl<'a> Cert<'a> {
169169
/// [EndEntityCert::verify_is_valid_for_subject_name].
170170
///
171171
/// [EndEntityCert::verify_is_valid_for_subject_name]: crate::EndEntityCert::verify_is_valid_for_subject_name
172-
pub fn valid_dns_names(&self) -> impl Iterator<Item = &str> {
172+
pub fn valid_dns_names(&self) -> impl Iterator<Item = &'a str> {
173173
NameIterator::new(self.subject_alt_name).filter_map(|result| {
174174
let GeneralName::DnsName(presented_id) = result.ok()? else {
175175
return None;
@@ -194,7 +194,7 @@ impl<'a> Cert<'a> {
194194
///
195195
/// This function returns URIs as strings without performing validation beyond checking that
196196
/// they are valid UTF-8.
197-
pub fn valid_uri_names(&self) -> impl Iterator<Item = &str> {
197+
pub fn valid_uri_names(&self) -> impl Iterator<Item = &'a str> {
198198
NameIterator::new(self.subject_alt_name).filter_map(|result| {
199199
let GeneralName::UniformResourceIdentifier(presented_id) = result.ok()? else {
200200
return None;

0 commit comments

Comments
 (0)