diff options
author | wbond <will@wbond.net> | 2017-02-27 06:52:50 -0500 |
---|---|---|
committer | wbond <will@wbond.net> | 2017-02-27 06:52:50 -0500 |
commit | ed82e3f593b9bc5c89a116b8f9116b226cecd614 (patch) | |
tree | 06b484b9016a89ead556357152c7719e9a07add4 /asn1crypto/x509.py | |
parent | 8c9011fbb8cf8bf95146a0f580fba66f92d68ecf (diff) | |
download | asn1crypto-ed82e3f593b9bc5c89a116b8f9116b226cecd614.tar.gz |
Allow x509.DNSName to start with a .
Diffstat (limited to 'asn1crypto/x509.py')
-rw-r--r-- | asn1crypto/x509.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/asn1crypto/x509.py b/asn1crypto/x509.py index efe6635..044eb10 100644 --- a/asn1crypto/x509.py +++ b/asn1crypto/x509.py @@ -90,6 +90,34 @@ class DNSName(IA5String): return self.contents.lower() == other.contents.lower() + def set(self, value): + """ + Sets the value of the DNS name + + :param value: + A unicode string + """ + + if not isinstance(value, str_cls): + raise TypeError(unwrap( + ''' + %s value must be a unicode string, not %s + ''', + type_name(self), + type_name(value) + )) + + if value.startswith('.'): + encoded_value = b'.' + value[1:].encode(self._encoding) + else: + encoded_value = value.encode(self._encoding) + + self._native = value + self.contents = encoded_value + self._header = None + if self._trailer != b'': + self._trailer = b'' + class URI(IA5String): |