def add_dns_id(self, dns_id, validate=True, ext_value=None): if validate: try: a_utils.verify_domain(dns_id, allow_wildcards=True) except ValueError as e: raise errors.X509Error("invalid domain provided: %s" % str(e)) new_pos = len(ext_value) ext_value[new_pos] = None ext_value[new_pos]['dNSName'] = dns_id return ext_value
def _valid_domains(csr): """Format of the domin names See RFC5280 section 4.2.1.6 / RFC6125 / RFC1034 """ sans = csr.get_extensions(extension.X509ExtensionSubjectAltName) if not sans: return ext = sans[0] for domain in ext.get_dns_ids(): try: util.verify_domain(domain, allow_wildcards=True) except ValueError as e: raise errors.ValidationError(str(e))
def _valid_domains(csr, label_re="^[a-z](?:[-a-z0-9]*[a-z0-9])?$"): """Format of the domin names See RFC5280 section 4.2.1.6 / RFC6125 / RFC1034 """ sans = csr.get_extensions(extension.X509ExtensionSubjectAltName) if not sans: return label_re_comp = re.compile(label_re, re.IGNORECASE) ext = sans[0] for domain in ext.get_dns_ids(): try: util.verify_domain(domain, label_re_comp, allow_wildcards=True) except ValueError as e: raise errors.ValidationError(str(e))