Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sample for changing CA certificate on IotHub #74

Open
MrVhek opened this issue Sep 21, 2021 · 0 comments
Open

Sample for changing CA certificate on IotHub #74

MrVhek opened this issue Sep 21, 2021 · 0 comments

Comments

@MrVhek
Copy link

MrVhek commented Sep 21, 2021

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 !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant