|
12 | 12 | // ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
13 | 13 | // OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
14 | 14 |
|
15 |
| -#[cfg(feature = "alloc")] |
16 |
| -use alloc::vec::Vec; |
17 |
| - |
18 | 15 | #[cfg(feature = "alloc")]
|
19 | 16 | use super::dns_name::GeneralDnsNameRef;
|
20 | 17 | use super::dns_name::{self, DnsNameRef};
|
@@ -320,35 +317,23 @@ impl<'a> Iterator for NameIterator<'a> {
|
320 | 317 | #[cfg(feature = "alloc")]
|
321 | 318 | pub(crate) fn list_cert_dns_names<'names>(
|
322 | 319 | cert: &'names crate::EndEntityCert<'names>,
|
323 |
| -) -> Result<impl Iterator<Item = GeneralDnsNameRef<'names>>, Error> { |
| 320 | +) -> impl Iterator<Item = GeneralDnsNameRef<'names>> { |
324 | 321 | let cert = &cert.inner();
|
325 |
| - let mut names = Vec::new(); |
326 |
| - |
327 |
| - let result = |
328 |
| - NameIterator::new(Some(cert.subject), cert.subject_alt_name).find_map(&mut |result| { |
329 |
| - let name = match result { |
330 |
| - Ok(name) => name, |
331 |
| - Err(err) => return Some(err), |
332 |
| - }; |
333 |
| - |
334 |
| - let presented_id = match name { |
335 |
| - GeneralName::DnsName(presented) => presented, |
336 |
| - _ => return None, |
337 |
| - }; |
338 |
| - |
339 |
| - // if the name could be converted to a DNS name, add it; otherwise, |
340 |
| - // keep going. |
341 |
| - if let Ok(name) = GeneralDnsNameRef::try_from_ascii(presented_id.as_slice_less_safe()) { |
342 |
| - names.push(name) |
343 |
| - } |
| 322 | + NameIterator::new(Some(cert.subject), cert.subject_alt_name).filter_map(|result| { |
| 323 | + let name = match result { |
| 324 | + Ok(name) => name, |
| 325 | + // Ignore invalid names, this is an informational function, not something used |
| 326 | + // during validation. |
| 327 | + Err(_) => return None, |
| 328 | + }; |
344 | 329 |
|
345 |
| - None |
346 |
| - }); |
| 330 | + let presented_id = match name { |
| 331 | + GeneralName::DnsName(presented) => presented, |
| 332 | + _ => return None, |
| 333 | + }; |
347 | 334 |
|
348 |
| - match result { |
349 |
| - Some(err) => Err(err), |
350 |
| - _ => Ok(names.into_iter()), |
351 |
| - } |
| 335 | + GeneralDnsNameRef::try_from_ascii(presented_id.as_slice_less_safe()).ok() |
| 336 | + }) |
352 | 337 | }
|
353 | 338 |
|
354 | 339 | // It is *not* valid to derive `Eq`, `PartialEq, etc. for this type. In
|
|
0 commit comments