-
Notifications
You must be signed in to change notification settings - Fork 378
Add Certificate Management support over Azure IoT Hub #1223
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
Open
ewertons
wants to merge
28
commits into
feature/iot-csr-preview
Choose a base branch
from
ewertons/iot-csr-preview
base: feature/iot-csr-preview
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
8359207
Partial work for CSR over IoT Hub
ewertons 3c65f26
Fix documentation
f4f2115
Implement async version of send_certificate_signing_request
bbbea0c
Delete CSR sample for DPS-only, under azure-iot-device
8aab8d4
Several little fixes
3b89ed9
Partial changes to implement CSR/IoT
f13c63b
Add stages, ops, events for CertificateSigningRequest
8cdb873
Complete CSR functionality
c5876b6
Update code documentation for CSR
526fd2c
Cleanup certificate_issuance.py (#1)
861ccd4
Add reconnection to certificate_issuance.py, cleanup
340d97a
Update CSR sample and its documentation
e63dc1d
Fix use of iothub_csr_data variable
76cea5c
Add cert mgmt pipeline yaml
ewertons 401577b
Rename certificate_management.md -> readme.md
ewertons 07179fa
Address CR comments (change env var name)
ewertons 7b7b5f3
Add credentialPolicyName on enrollment creation requests
ewertons 158ee6e
Remove previous ClientCertificateIssuancePolicy construct
ewertons e1beadc
Add env var generation cmdlet, re-enable build and tests
ewertons f831984
Pass private key password only if defined as a non-empty string
ewertons 7da5ed4
Adjust Dps service API version for cert mgmt (2021-10-01)
ewertons b578023
Adjust Dps service API version for cert mgmt (try 2025-07-01-preview)
ewertons a171acb
Add e2e tests for certificate signing request
ewertons bde4ea9
device_client.send_certificate_signing_request to take args directly
ewertons 5fc8926
Address CR comments
ewertons 36436cb
Expose csr request_id on public API functions
ewertons 53c86b5
Pass request_id on csr e2e test
ewertons 93a1dcb
Pass request_id on csr e2e test
ewertons File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
azure-iot-device/azure/iot/device/iothub/models/certificate_signing_request.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| # ------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. See License.txt in the project root for | ||
| # license information. | ||
| # -------------------------------------------------------------------------- | ||
| """This module contains a class representing messages that are sent or received. | ||
| """ | ||
|
|
||
|
|
||
| class CertificateSigningRequest(object): | ||
| """Represents a Certificate Signing Request message to Azure IoT Hub | ||
|
|
||
| :ivar csr: The base64-encoded certificate signing request. | ||
| :ivar replace: Replace any active credential operation for this device. | ||
| """ | ||
|
|
||
| def __init__(self, request_id, csr, replace): | ||
| """ | ||
| Initializer for CertificateSigningRequest | ||
|
|
||
| :param str request_id: The unique identifier for the certificate signing request. | ||
| :param str csr: The base64-encoded certificate signing request. | ||
| :param str replace: Replace any active credential operation for this device. | ||
| """ | ||
| if request_id is None: | ||
| raise ValueError("Certificate Signing Request ID cannot be None.") | ||
|
|
||
| if csr is None: | ||
| raise ValueError("Certificate Signing Request cannot be None.") | ||
|
|
||
| self.request_id = request_id | ||
| self.id = None # The device id, filled internally by the pipeline configuration. | ||
| self.csr = csr | ||
| self.replace = replace | ||
|
|
||
| def __str__(self): | ||
| return str(self.csr) | ||
|
|
||
| # Used for json serialization of CertificateSigningRequest. | ||
| def to_dict(obj): | ||
| data = obj.__dict__.copy() | ||
ewertons marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| data.pop("request_id") # request_id should not be serialized | ||
| return data | ||
|
|
||
|
|
||
| class CertificateSigningResponse(object): | ||
| """Represents a Certificate Signing Response message from Azure IoT Hub | ||
|
|
||
| :ivar status_code: The result code for the certificate signing request. | ||
| :ivar certificates: An array with the base64-encoded issued certificate chain (leaf, intermediate and root, in this order). | ||
| """ | ||
|
|
||
| def __init__(self, status_code, certificates): | ||
| """ | ||
| Initializer for CertificateSigningResponse | ||
|
|
||
| :param status_code: The result code for the certificate signing request. | ||
| :param certificates: An array with the base64-encoded issued certificate chain (leaf, intermediate and root, in this order). | ||
| """ | ||
| self.status_code = status_code | ||
| self.certificates = certificates | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,6 +8,7 @@ | |
|
|
||
| # Feature names | ||
| C2D_MSG = "c2d" | ||
| CSR = "csr" | ||
| INPUT_MSG = "input" | ||
| METHODS = "methods" | ||
| TWIN = "twin" | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.