'Validates that a given hostname is valid for an SSL certificate.
Args:
cert: A dictionary representing an SSL certificate.
hostname: The hostname to test.
Returns:
bool: Whether or not the hostname is valid for this certificate.'

def _ValidateCertificateHostname(self, cert, hostname):

    hosts = self._GetValidHostsForCert(cert)
    for host in hosts:
        host_re = host.replace('.', '\\.').replace('*', '[^.]*')
        if re.search(('^%s$' % (host_re,)), hostname, re.I):
            return True
        return False
