Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def get_acme_client_and_key(self, acme_directory_uri, tos=False):
data = self.middleware.call_sync('acme.registration.query', [['directory', '=', acme_directory_uri]])
if not data:
data = self.middleware.call_sync(
'acme.registration.create',
{'tos': tos, 'acme_directory_uri': acme_directory_uri}
)
else:
data = data[0]
# Making key now
key = jose.JWKRSA.fields_from_json(json.loads(data['body']['key']))
key_dict = key.fields_to_partial_json()
# Making registration resource now
registration = messages.RegistrationResource.from_json({
'uri': data['uri'],
'terms_of_service': data['tos'],
'body': {
'contact': [data['body']['contact']],
'status': data['body']['status'],
'key': {
'e': key_dict['e'],
'kty': 'RSA',
'n': key_dict['n']
}
}
})
def update_txt_record(self, data):
authenticator = self.middleware.call_sync('acme.dns.authenticator._get_instance', data['authenticator'])
return self.__getattribute__(
f'update_txt_record_{authenticator["authenticator"].lower()}'
)(
data['domain'],
messages.ChallengeBody.from_json(json.loads(data['challenge'])),
jose.JWKRSA.fields_from_json(json.loads(data['key'])),
**authenticator['attributes']
)