diff --git a/letsencrypt/acme/messages2.py b/letsencrypt/acme/messages2.py index ec1d1ad1d..37a384aa4 100644 --- a/letsencrypt/acme/messages2.py +++ b/letsencrypt/acme/messages2.py @@ -117,7 +117,7 @@ class RegistrationResource(Resource): :ivar new_authz_uri: URI found in the 'next' Link header """ - __slots__ = ('body', 'uri', 'new_authz_uri') + __slots__ = ('body', 'uri', 'new_authz_uri', 'terms_of_service') class Registration(ResourceBody): @@ -128,6 +128,7 @@ class Registration(ResourceBody): key = jose.Field('key', omitempty=True, decoder=jose.JWK.from_json) contact = jose.Field('contact', omitempty=True, default=()) recovery_token = jose.Field('recoveryToken', omitempty=True) + agreement = jose.Field('agreement', omitempty=True) class ChallengeResource(Resource, jose.JSONObjectWithFields): diff --git a/letsencrypt/client/network2.py b/letsencrypt/client/network2.py index c27d9e40c..8bfc12a15 100644 --- a/letsencrypt/client/network2.py +++ b/letsencrypt/client/network2.py @@ -36,14 +36,19 @@ class Network(object): def register(self, contact=messages2.Registration._fields['contact'].default): new_reg = messages2.Registration(contact=contact) + response = self._post(self.new_reg_uri, self._wrap_in_jws(new_reg)) assert response.status_code == httplib.CREATED # TODO: handle errors + + terms_of_service = (response.links['next']['url'] + if 'terms-of-service' in response.links else None) regr = messages2.RegistrationResource( body=messages2.Registration.from_json(response.json()), uri=response.headers['location'], new_authz_uri=response.links['next']['url'], - ) + terms_of_service=terms_of_service) assert regr.body.key == self.key.public() + return regr def update_registration(self, regr):