azure-samples-python-management icon indicating copy to clipboard operation
azure-samples-python-management copied to clipboard

Sample for changing CA certificate on IotHub

Open MrVhek opened this issue 4 years ago • 0 comments

Hello,

I've been struggling finding some samples that will allows me to change/add CA certificate to my IotHub instance. Is there any sample available ?

Here what I began to do, but it doesn't work...

new_cert_pem: str = "---BEGIN CERTIFICATE----aaag..." # PEM format
environ['AZURE_CLIENT_ID'] = ""
environ['AZURE_TENANT_ID'] = ""
environ['AZURE_CLIENT_SECRET'] = ""
iothub_client = IotHubClient(
   credential=DefaultAzureCredential(),
   subscription_id=environ['AZ_SUBCRIPTION_ID']
)
iothub_client.certificates.create_or_update(
   resource_group_name="iothub",
   resource_name="myiothub",
   certificate_name="CA-TO-ADD"
   certificate_description=CertificateBodyDescription(
       certificate=new_cert_pem.decode('utf8'),
       is_verified=True
   )
)

Thanks for your help !

MrVhek avatar Sep 21 '21 12:09 MrVhek