diff --git a/certbot_azure/dns_azure.py b/certbot_azure/dns_azure.py index 54217f0..758755f 100644 --- a/certbot_azure/dns_azure.py +++ b/certbot_azure/dns_azure.py @@ -1,11 +1,12 @@ """DNS Authenticator for Azure DNS.""" +import json import logging import os import zope.interface +from azure.identity import ClientSecretCredential from azure.mgmt.dns import DnsManagementClient -from azure.common.client_factory import get_client_from_auth_file from azure.mgmt.dns.models import RecordSet, TxtRecord from msrestazure.azure_exceptions import CloudError @@ -102,8 +103,21 @@ class _AzureClient(object): def __init__(self, resource_group, account_json=None): self.resource_group = resource_group - self.dns_client = get_client_from_auth_file(DnsManagementClient, - auth_path=account_json) + with open(account_json) as json_file: + json_dict = json.load(json_file) + + credential = ClientSecretCredential( + tenant_id = json_dict["tenantId"], + client_id = json_dict["clientId"], + client_secret = json_dict["clientSecret"], + authority=json_dict["activeDirectoryEndpointUrl"], + ) + self.dns_client = DnsManagementClient( + credential, + json_dict["subscriptionId"], + base_url=json_dict["resourceManagerEndpointUrl"], + credential_scopes=["{}/.default".format(json_dict["resourceManagerEndpointUrl"])], + ) def add_txt_record(self, domain, record_content, record_ttl): """ @@ -161,7 +175,7 @@ def _find_managed_zone(self, domain): azure_zones = self.dns_client.zones.list() # TODO - catch errors azure_zones_list = [] while True: - for zone in azure_zones.current_page: + for zone in azure_zones: azure_zones_list.append(zone.name) azure_zones.next() except StopIteration: diff --git a/requirements.txt b/requirements.txt index 47338d7..0100ec0 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,11 +6,11 @@ azure-mgmt-resource==10.1.0 azure-mgmt-dns>=3.0.0 configobj==5.0.6 coverage==5.2.1 -cryptography==3.2 +cryptography==43.0.1 decorator==4.4.2 docutils==0.16 entrypoints==0.3 -httplib2==0.18.1 +httplib2==0.19.0 logger==1.4 mock==4.0.2 msrest==0.6.18 diff --git a/setup.py b/setup.py index 1ca2011..6b4c269 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ from distutils.core import setup from setuptools import find_packages -version = '0.1.0' +version = '0.1.1' install_requires = [ 'acme>=0.29.0',