1313// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1414
1515use crate :: {
16- cert, name, signed_data, verify_cert, DnsNameRef , Error , SignatureAlgorithm , Time ,
16+ cert, name, signed_data, verify_cert, Error , Name , SignatureAlgorithm , Time ,
1717 TlsClientTrustAnchors , TlsServerTrustAnchors ,
1818} ;
1919
@@ -27,7 +27,7 @@ use alloc::vec::Vec;
2727///
2828/// * `EndEntityCert.verify_is_valid_tls_server_cert`: Verify that the server's
2929/// certificate is currently valid *for use by a TLS server*.
30- /// * `EndEntityCert.verify_is_valid_for_dns_name `: Verify that the server's
30+ /// * `EndEntityCert.verify_name `: Verify that the server's
3131/// certificate is valid for the host that is being connected to.
3232/// * `EndEntityCert.verify_signature`: Verify that the signature of server's
3333/// `ServerKeyExchange` message is valid for the server's certificate.
@@ -37,8 +37,8 @@ use alloc::vec::Vec;
3737///
3838/// * `EndEntityCert.verify_is_valid_tls_client_cert`: Verify that the client's
3939/// certificate is currently valid *for use by a TLS client*.
40- /// * `EndEntityCert.verify_is_valid_for_dns_name ` or
41- /// `EndEntityCert.verify_is_valid_for_at_least_one_dns_name `: Verify that the
40+ /// * `EndEntityCert.verify_name ` or
41+ /// `EndEntityCert.verify_for_at_least_one_name `: Verify that the
4242/// client's certificate is valid for the identity or identities used to
4343/// identify the client. (Currently client authentication only works when the
4444/// client is identified by one or more DNS hostnames.)
@@ -140,8 +140,10 @@ impl<'a> EndEntityCert<'a> {
140140 }
141141
142142 /// Verifies that the certificate is valid for the given DNS host name.
143- pub fn verify_is_valid_for_dns_name ( & self , dns_name : DnsNameRef ) -> Result < ( ) , Error > {
144- name:: verify_cert_dns_name ( & self , dns_name)
143+ pub fn verify_for_name ( & self , name : Name ) -> Result < ( ) , Error > {
144+ match name {
145+ Name :: DnsName ( dns_name) => name:: verify_cert_dns_name ( & self , dns_name) ,
146+ }
145147 }
146148
147149 /// Verifies that the certificate is valid for at least one of the given DNS
@@ -154,12 +156,12 @@ impl<'a> EndEntityCert<'a> {
154156 /// Requires the `alloc` default feature; i.e. this isn't available in
155157 /// `#![no_std]` configurations.
156158 #[ cfg( feature = "alloc" ) ]
157- pub fn verify_is_valid_for_at_least_one_dns_name < ' names > (
159+ pub fn verify_for_at_least_one_name < ' names > (
158160 & self ,
159- dns_names : impl Iterator < Item = DnsNameRef < ' names > > ,
160- ) -> Result < Vec < DnsNameRef < ' names > > , Error > {
161- let result: Vec < DnsNameRef < ' names > > = dns_names
162- . filter ( |n| self . verify_is_valid_for_dns_name ( * n) . is_ok ( ) )
161+ dns_names : impl Iterator < Item = Name < ' names > > ,
162+ ) -> Result < Vec < Name < ' names > > , Error > {
163+ let result: Vec < Name < ' names > > = dns_names
164+ . filter ( |n| self . verify_for_name ( * n) . is_ok ( ) )
163165 . collect ( ) ;
164166 if result. is_empty ( ) {
165167 return Err ( Error :: CertNotValidForName ) ;
0 commit comments