aboutsummaryrefslogtreecommitdiff
path: root/asn1crypto/x509.py
diff options
context:
space:
mode:
authorwbond <will@wbond.net>2017-02-27 06:52:50 -0500
committerwbond <will@wbond.net>2017-02-27 06:52:50 -0500
commited82e3f593b9bc5c89a116b8f9116b226cecd614 (patch)
tree06b484b9016a89ead556357152c7719e9a07add4 /asn1crypto/x509.py
parent8c9011fbb8cf8bf95146a0f580fba66f92d68ecf (diff)
downloadasn1crypto-ed82e3f593b9bc5c89a116b8f9116b226cecd614.tar.gz
Allow x509.DNSName to start with a .
Diffstat (limited to 'asn1crypto/x509.py')
-rw-r--r--asn1crypto/x509.py28
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):