Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions certbot_azure/dns_azure.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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):
"""
Expand Down Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down