def raise_hostname(certificate, hostname):
is_ip = re.match('<STR_LIT>', hostname) or hostname.find('<STR_LIT::>') != -<NUM_LIT:1><EOL>if is_ip:<EOL><INDENT>hostname_type = '<STR_LIT>' % hostname<EOL><DEDENT>else:<EOL><INDENT>hostname_type = '<STR_LIT>' % hostname<EOL><DEDENT>message = '<STR_LIT>' % hostname_type<EOL>valid_ips = '<STR_LIT:U+002CU+0020>'.join(certificate.valid_ips)<EOL>valid_domains = '<STR_LIT:U+002CU+0020>'.join(certificate.valid_domains)<EOL>if valid_domains:<EOL><INDENT>message += '<STR_LIT>' % valid_domains<EOL><DEDENT>if valid_domains and valid_ips:<EOL><INDENT>message += '<STR_LIT>'<EOL><DEDENT>if valid_ips:<EOL><INDENT>message += '<STR_LIT>' % valid_ips<EOL><DEDENT>raise TLSVerificationError(message, certificate)<EOL>
Raises a TLSVerificationError due to a hostname mismatch

:param certificate:
    An asn1crypto.x509.Certificate object

:raises:
    TLSVerificationError