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

device update with x509 certificate #48

Closed
PradeepKiruvale opened this issue Apr 22, 2021 · 7 comments
Closed

device update with x509 certificate #48

PradeepKiruvale opened this issue Apr 22, 2021 · 7 comments
Assignees

Comments

@PradeepKiruvale
Copy link

Hi All,

We were playing around with the device update agent, connecting to Azure, update the device software packages. We could connect the agent to Azure using the Shared Acess keys. But is there any way to do it using the x509 certs?. Please guide us if there any documents or links to some blogs.

@ValOlson
Copy link
Contributor

Hello,

Thank you for your question. You can connect the Device Update agent as a Module (see how to) only using the SAS key because we have a current limitation on the support from IoT Identity Service . This should be expanded in the future.

Alternatively if you are ok with using the Device identity, you can connect the Device Update agent using SAS keys, TPM or x509 certs (see how to).

@PradeepKiruvale
Copy link
Author

Thanks for your answer. But the second part of your answer about using the device identity to connect the device agent to azure is not so clear to me from the link. Could you please help me, how can we use certificates?

@nihemstr
Copy link
Contributor

Hey Pradeep,

Sorry this took so long I had to follow up with some of our internal partners to make sure I understood what the process would be for you and if we natively supported the scenario you're discussing.

From what I gather you're trying to run the DU agent which will connect to an IotHub device (not a module) using an x509 certificate without using IotEdge. We don't currently support connecting using self-signed x509 certificates out of the box without IotEdge but I outline a method for doing so if you want to take our reference agent and make the code changes yourself.

To make this work you'll need to follow the next three steps. Please note that only the third step requires you to crack open the agent and add some code.

  1. Create the primary and secondary certificates you want to use for the connection. You can read generally about how the IotHub uses x509 certificates and how they apply to the configuration of your devices here
    1. For the development environment you can generate self-signed certificates using the steps found here
    2. For production environments you should be using CA signed certificates obtained from your Certified Authority.Learn more here
  2. Once you've generated your certificates and gotten your x509 thumbprints you simply need to create the device
    1. For both Iot Devices and Iot Edge Devices you simply need to navigate to the IotHub on which you wish to create these devices, select "New" under the Iot Devices or IotEdge Devices leaf (Microsoft for the sidebar tab)
    2. In the information panel you must select either X.509 Self-Signed or X.509 CA Signed depending on what kind of certificate you generated in (1). Please note that for any and all production environments you should be using CA signed certificates. Self-Signed certificates should only ever be used in development phases.
    3. Enter the thumbprints for the primary and secondary certificates obtained above into their respective fields.
    4. Press "Save"
    5. You should now be looking at your fancy new x509 authenticating device!
  3. Setup DU to use the certificates in your device
    1. First please take a look at the sample that accomplishes your scenario here
    2. You'll notice that you need to include the certificates and private keys that you generated and then took the thumbprint of to create your IotHub device in either plaintext or add a method for ADU to read them into the main.c so they can be added to your device handle like below (from the sample)
(IoTHubDeviceClient_LL_SetOption(device_ll_handle, OPTION_X509_CERT, x509certificate) != IOTHUB_CLIENT_OK) || (IoTHubDeviceClient_LL_SetOption(device_ll_handle, OPTION_X509_PRIVATE_KEY, x509privatekey) != IOTHUB_CLIENT_OK)
  1. Within the DU agent we add these kind of additions within this fucntion
  2. If you were trying to be fancy I would suggest adding a parameter to the adu-conf.txt configuration file that has the absolute path to your certificate and private key within our GetConnectionInfoFromADUConfigFile() function located here. Now you can add some functionality to read in the certificate and private key into the agent.
  3. Then you can just add your connection string, x509CertificatePath, and privateKeyPath to the configuration file to get those values into the agent.
  4. Once you are reading those values in you can add new variables to our ADUC_LaunchArguments structure or reuse old ones so you can pass your certificate and private key that you added above to the ADUC_DeviceClientCreate function
  5. The final step would to be add the options above to the clientHandle being created in ADUC_DeviceCLientCreate. I wrote the code that should work if you want to add it within the if-else-if structure we have within ADUC_DeviceClientCreate. For the code I assumed you added the new member values of selfSignedCertificateString and selfSignedPrivateKey to the ADUC_LaunchArguments structure for your certificate and private key strings read into the agent above
    else if (
        connInfo->selfSignedCertificateString != NULL 
        && (iothubResult = IoTHubDeviceClient_LL_SetOption(g_iotHubClientHandle,OPTION_X509_CERT,connInfo->selfSignedCertificateString) != IOTHUB_CLIENT_OK))
    {
        Log_Error("Unable to set certificate string for validation");
        result = false;
    }
    else if (
        connInfo->selfSignedPrivateKey != NULL 
        && (iothubResult = IoTHubDeviceClient_LL_SetOption(g_iotHubClientHandle,OPTION_X509_PRIVATE_KEY,connInfo->selfSignedPrivateKey) != IOTHUB_CLIENT_OK))
    {
        Log_Error("Unable to set private key string for validation");
        result = false;
    }
  1. You should then be able to build the agent for use on linux platforms and ready to deploy APT updates using ./scripts/build.sh -p linux --content-handlers microsoft/apt --build-packages. Then install the agent using debian, add your variables to the adu-conf.txt and then get right on going.

I want to let you know we're looking into support this out of the box but I don't have a timeline for you. that's why I figured I'd get you the code and steps that will at least get you going right now until we have a more robust solution.

Let me know if you have any questions.

-Nic Hemstreet
Software Engineer, Adu Client

@nihemstr nihemstr self-assigned this Apr 28, 2021
@PradeepKiruvale
Copy link
Author

@nihemstr Thanks for the detailed explanation. You are right I am trying to connect my iot device directly to the IoThub without using the IotEdge. My question here is, Is it common practice to connect IoT devices with IotEdge or directly?. Which is better?

Now I have an environment wherein I connect the IoT Device using the x509 self-signed certificate to IoTHub.

@ValOlson
Copy link
Contributor

Hello,

It is great to hear that this is what you were looking for!

Connecting the IoT device with the IoT Identity Service (works with IoTEdge and non-Edge devices) or not depends on your use case. For development and when using a few devices, it’s more convenient to use config file. But for production, it is recommended to use the IoT Identity service for scalability and security.

shiyi-peng pushed a commit that referenced this issue May 24, 2021
* Squashed commit of the following:

commit f6026697c567ea260e296bf9260db94713e231b0
Author: Nox-MSFT <55153324+Nox-MSFT@users.noreply.github.com>
Date:   Thu Apr 23 17:17:23 2020 -0700

    Refactor IsInstalled() logic. Make Sandbox’s permission RWX. Consume libdocsdk.so (#76)

    Fixed bug where DSMHandler::IsInstalled() throw after failed to create a plugin, due to missing DSM file in Sadbox folder.

    Refactor how we handle the case where DSM file is missing.

    Will revisit DSMHandler design after private preview.

    Also link to libdocsdk.so instead of libdocsdk.a to avoid binary mismatch issue.

    Bugs

    Bug 25997916: Deployment to ADU Client fails at IsInstalled with unhandled exception [callresultmethodandhandleexceptions]

    Bug 26013591: ADU client need to use new DO-SDK version (may also need to update build pipeline)

commit 5ee97f6e32bc5b8ed101bbc8d3c136ed386c9468
Author: Nicholas Hemstreet <62158276+nihemstr@users.noreply.github.com>
Date:   Wed Apr 22 15:29:33 2020 -0700

    ReadConnectionStrFromFile will only return buffer insufficient if the… (#77)

    * ReadConnectionStrFromFile will only return buffer insufficient if the first line cannot be entirely read from the file

    * Updated method for checking buffer overflow and changed some character lines

    * Removed needless removal of the flag

commit dbf83a9123d97e8c4d0310491070854627ec8fa3
Author: Nox-MSFT <55153324+Nox-MSFT@users.noreply.github.com>
Date:   Tue Apr 14 22:15:05 2020 -0700

    Include libcpprest in dependencies list (#75)

commit 349c8ebfbb2834db8c200caa7b86983d9c7e3ce8
Author: Casey Irvine <44978150+cirvine-MSFT@users.noreply.github.com>
Date:   Mon Apr 13 17:56:01 2020 -0700

    Write swupdate logs to same folder as client + image doc updates. (#73)

    * Updating adu_install.sh with log option

    * Updating adu_install with log_dir

    * Fixing shellcheck errors

    * Fixing issue with missing -l option

    * Updating docs

    * Addressing PR feedback

    Co-authored-by: Casey Irvine <casey.d.irvine@gmail.com>

commit 2fd1f7594d32388a0dfadfdccafaa64a5d0d3b6b
Author: Carmen Forsmann <cmforsmann@live.com>
Date:   Mon Apr 13 16:03:42 2020 -0700

    Update desired-state-manifest.md broken images (#74)

    * Update desired-state-manifest.md

    * Update desired-state-manifest.md

    * Update desired-state-manifest.md

    * Update desired-state-manifest.md

    * Added cumulative image for better fit

    * Update desired-state-manifest.md

    * Update desired-state-manifest.md

    * Update desired-state-manifest.md

commit 54570f90002e5126144e81f35ce51af392c81378
Author: vimeht <59975079+vimeht@users.noreply.github.com>
Date:   Mon Apr 13 13:20:46 2020 -0700

    Update desired-state-manifest.md (#68)

    * Update desired-state-manifest.md

    updating to add guidelines for creating a dsm

    * Add files via upload

    * Update desired-state-manifest.md

    * Delete cumulativeDSM1.PNG

    * Add files via upload

    * Add files via upload

    * Delete cumulativeDSM1.PNG

    * Delete cumulativeDSM2.PNG

    * Delete cumulativeDSM3.PNG

    Co-authored-by: Jerry-GeGarcia <54458572+Jerry-GeGarcia@users.noreply.github.com>

commit 6b1088279c7a29e79ffcfd18d85948b43aabadd8
Author: vimeht <59975079+vimeht@users.noreply.github.com>
Date:   Mon Apr 13 13:19:49 2020 -0700

    Update how-to-publish-quickstart.md (#69)

    * Update how-to-publish-quickstart.md

    Updating wording to include both image and DSM. Scripts still need to be updated. Will be done in another pass

    * Update docs/quickstarts/how-to-publish-quickstart.md

    Co-Authored-By: Casey Irvine <44978150+cirvine-MSFT@users.noreply.github.com>

    * Update how-to-publish-quickstart.md

    * Update how-to-client-eval-sim-quickstart.md

    Co-authored-by: Casey Irvine <44978150+cirvine-MSFT@users.noreply.github.com>
    Co-authored-by: Jerry-GeGarcia <54458572+Jerry-GeGarcia@users.noreply.github.com>

commit 4a12c08a8055103c89605cdee7e0a775079f57e0
Author: Nox-MSFT <55153324+Nox-MSFT@users.noreply.github.com>
Date:   Fri Apr 10 12:38:47 2020 -0700

    Changed  Aduc agent (simulator) default log dir to /tmp/aduc-logs. And minor comment improvement. (#70)

    Set default log dir for "simulator" build to /tmp/aduc-logs
    Update comment for safe_json_serialize_to_file_pretty.

commit f2b67ca9672898d97e485c7e970c4d65689f636c
Author: Casey Irvine <44978150+cirvine-MSFT@users.noreply.github.com>
Date:   Fri Apr 10 10:10:46 2020 -0700

    Fixing typo in CMakeLists.txt (#72)

commit 3e509ccf2128867e20ec854f248268a53c041805
Author: Casey Irvine <44978150+cirvine-MSFT@users.noreply.github.com>
Date:   Fri Apr 10 00:34:32 2020 -0700

    Fixing package dependency on DO (#71)

    Changed dependency on do-client-lite to ms-doclient-lite
    Added ms-dopapt as a Suggested package.

commit 2da9e0929622b16116c9a0039833b64ee554b99d
Author: Nox-MSFT <55153324+Nox-MSFT@users.noreply.github.com>
Date:   Thu Apr 9 10:24:50 2020 -0700

    Changed installedCriteria file folder and persist timestamp. Changed package version string format.   (#64)

    Saving installedCriteria data to /var/lib/adu/installedcriteria file.
    Persist timestamp as part of installedCriteria data.
    Change package version string format. (Remove '=' sign) and updated the document.
    Add more unit tests

commit 78acc5ee9aa2148415fc09f2b1c875f74641888f
Author: Casey Irvine <44978150+cirvine-MSFT@users.noreply.github.com>
Date:   Wed Apr 8 23:51:36 2020 -0700

    Fixing issues reporting JSON in InstalledContentId (#66)

    * Fixing issues reporting JSON in InstalledContentId
    * Using Parson instead of snprintf to serialize JSON.
    * Fixing references to adu-install.sh
    * Ran sh-format.sh on adu_install.sh

commit b6d652def464cf8032c72a4ac3313eeac11f41c9
Author: Casey Irvine <44978150+cirvine-MSFT@users.noreply.github.com>
Date:   Wed Apr 8 17:56:18 2020 -0700

    Merging latest master into dev/package-update (#65)

    * Adding documentation for Yocto and improved details about ADU reference client (#42)

    * improved client docs

    * clean-up of new file

    * Update docs/linux-reference-client/client-overview.md

    Co-Authored-By: Casey Irvine <44978150+cirvine-MSFT@users.noreply.github.com>

    * address PR feedback

    * fix typo

    * update simulator documentation

    * update shell commands and markdown spacing

    Co-authored-by: Casey Irvine <44978150+cirvine-MSFT@users.noreply.github.com>

    * update simulator command and typo for client overview (#45)

    * update simulator command and typo for client overview

    * remove sudo from command

    * Adding signed ADU-Management cmdlets, signed and modified ADU-Content… (#37)

    * Adding signed ADU-Management cmdlets, signed and modified ADU-Content cmdlets
    * Modifying gitignore files

    * User/chrudrap/add signed cmdlets (#52)

    Bug fix in the setup script - loading MSAL.NET to path

    * Andbrown03312020 (#55)

    * Update how-to-publish-quickstart.md

    * Update how-to-publish-quickstart.md

    * Add install-prefix option to the build.sh script. (#62)

    * Add install-prefix option to the build.sh script.

    * Apply suggestions from code review

    Co-Authored-By: Casey Irvine <44978150+cirvine-MSFT@users.noreply.github.com>

    * Fix indentation

    Co-authored-by: Casey Irvine <44978150+cirvine-MSFT@users.noreply.github.com>

    * Fixing deleted line in merge.

    * Apply suggestions from code review

    Co-authored-by: Carmen Forsmann <cmforsmann@live.com>
    Co-authored-by: Chinmay Rudrapatna <59946089+chrudrap@users.noreply.github.com>
    Co-authored-by: Andrew Brown <59940770+andrewbrownmsft@users.noreply.github.com>
    Co-authored-by: Emre Girgin <50592283+mrgirgin@users.noreply.github.com>

commit 25736479750063a1cb97e9a28f9cd4e8f7d9478c
Author: Casey Irvine <44978150+cirvine-MSFT@users.noreply.github.com>
Date:   Wed Apr 8 16:14:26 2020 -0700

    Fixing debian package version. (#63)

    Replacing '-' with '~' in our semantic version
    to make it debian version schema compliant.

commit c4223196b6d7a1132eff47fc485d5450b7490dd4
Author: Nox-MSFT <55153324+Nox-MSFT@users.noreply.github.com>
Date:   Tue Apr 7 14:40:55 2020 -0700

    Preserve existing config.yaml on update. Fail when download bogus package. IsInstalled unittest. Code clean up. (#61)

    Add a default Dpkg options to preserve exising config.yaml file when upgrading packages.

    Fix bug where Download() succeeded when specified a bogus package.

    Some code clean up.

    Refactor apt_pkg_helper to throw exception in come cases.

    Add package "update" unit test

    Add IsInstalled() unit test

commit 88c2fde33d2d6a745e2aebc4d9a4e57aab4fa862
Author: Casey Irvine <44978150+cirvine-MSFT@users.noreply.github.com>
Date:   Tue Apr 7 10:41:06 2020 -0700

    Fixing issue with reading config file. (#57)

    * Fixing adu config file path.

commit 97898e929d8f8a2438755becc7cc932348e594bc
Author: Casey Irvine <44978150+cirvine-MSFT@users.noreply.github.com>
Date:   Tue Apr 7 09:14:22 2020 -0700

    Making daemon run as root. (#58)

    * Making daemon run as root.

commit cc28c764d5d312cd2961153423ee0aab55ebad04
Author: Casey Irvine <44978150+cirvine-MSFT@users.noreply.github.com>
Date:   Tue Apr 7 08:56:28 2020 -0700

    Fixing PersistInstalledCriteria return value. (#60)

    * Fixing PersistInstalledCriteria return value.

commit 42934b94ba5c9b402e88fcbb79e1a73202f09f5e
Author: Casey Irvine <44978150+cirvine-MSFT@users.noreply.github.com>
Date:   Tue Apr 7 07:10:54 2020 -0700

    Fix DSM APT version specifier format ('=' not '==') (#59)

    * Fix dsm version specifier

    * Addressing PR feedback.

commit 1fdd33bd700b4f46900bb2c5d36b2e3cede0514d
Author: Casey Irvine <44978150+cirvine-MSFT@users.noreply.github.com>
Date:   Fri Apr 3 16:41:27 2020 -0700

    Merging latest master branch into dev/package-update (#56)

    * Adding documentation for Yocto and improved details about ADU reference client (#42)

    * improved client docs

    * clean-up of new file

    * Update docs/linux-reference-client/client-overview.md

    Co-Authored-By: Casey Irvine <44978150+cirvine-MSFT@users.noreply.github.com>

    * address PR feedback

    * fix typo

    * update simulator documentation

    * update shell commands and markdown spacing

    Co-authored-by: Casey Irvine <44978150+cirvine-MSFT@users.noreply.github.com>

    * update simulator command and typo for client overview (#45)

    * update simulator command and typo for client overview

    * remove sudo from command

    * Adding signed ADU-Management cmdlets, signed and modified ADU-Content… (#37)

    * Adding signed ADU-Management cmdlets, signed and modified ADU-Content cmdlets
    * Modifying gitignore files

    * User/chrudrap/add signed cmdlets (#52)

    Bug fix in the setup script - loading MSAL.NET to path

    * Andbrown03312020 (#55)

    * Update how-to-publish-quickstart.md

    * Update how-to-publish-quickstart.md

    Co-authored-by: Carmen Forsmann <cmforsmann@live.com>
    Co-authored-by: Chinmay Rudrapatna <59946089+chrudrap@users.noreply.github.com>
    Co-authored-by: Andrew Brown <59940770+andrewbrownmsft@users.noreply.github.com>

commit 4db0505c06d8be1d36ff79797d3c5a291b3b8f32
Author: Casey Irvine <44978150+cirvine-MSFT@users.noreply.github.com>
Date:   Fri Apr 3 16:00:55 2020 -0700

    Fixing directory permissions and setting up permissions with DO. (#48)

commit 3f143076808d62077fde735a6821a48a07414094
Author: Nox-MSFT <55153324+Nox-MSFT@users.noreply.github.com>
Date:   Fri Apr 3 10:44:44 2020 -0700

    Implemented APT DSM Handler plugin (#50)

    * Upper layer DSM Handler integration
    * DSM Handler implementation
    * DSM Parser component
    * APT DSM Handler plugin
    * Unit tests for DSMParser & APT DSM Handler plugin
    * Apt-Pkg library helper component

commit 6c1e06871fc27ec1747617a8402690b648e6c512
Author: Nicholas Hemstreet <62158276+nihemstr@users.noreply.github.com>
Date:   Thu Apr 2 16:12:13 2020 -0700

    User/nihemstr/local store eis merge branch (#51)

    * Refactor for V2 ADU Core interface. (#30)

    Added ADU Core V2 interface implementation behind ifdefs.
    Refactored platform layer and content handler code.
    Moved some common code into libraries.
    Renamed files to be consistent.

    * Finishing ADU Core V2 PnP interface implementation (#38)

    Some small refactors.
    Addressed TODOs.
    Added exceptions.
    Moved hash functions into a library.

    * Create connection utils library and included it in main

    * Moved connection_utils to utils folder, added unit tests

    * Removed extraneous dependency

    * Removed unit tests and umock implementation, will resolve later in new branch

    * Removed ADU_CAS_FILE in favour of ADU_CONF_FILE

    * Removed merge goof that had two definitions of ADUC_MethodCall_IsInstalled

    * Provided a more verbose log error so user understands where the connection method comes from

    * Fixed naming conventions, minor merge errors, and ran clang-tidy

    * Added more verbose enum names in-keeping with the current project

    * Updated code with clang format, changed file reading method to gets, and responded to other PR concerns

    * Repsonded to PR concerns, tweaked some function and variable names, and added some better Logging messages

    * Added more verbose feedback from ReadConnectionStrFromFile and improved some comments

    * Fixed issues with some of the ReadConStrErrCode values and how ADU detects an insufficient buffer in ReadConStr

    * Fixed naming errors and improperly labeled logging tools, closed a memory leak

    Co-authored-by: Casey Irvine <44978150+cirvine-MSFT@users.noreply.github.com>

commit 932d34f0f9cea7c92155ec3e35320f22d7e97aed
Author: vimeht <59975079+vimeht@users.noreply.github.com>
Date:   Thu Apr 2 12:37:02 2020 -0700

    Update adu-overview.md (#54)

    Edits to ADU overview for package update

commit 5d3387d4547e43eb1ef711090f6a13a1694b9643
Author: Casey Irvine <44978150+cirvine-MSFT@users.noreply.github.com>
Date:   Tue Mar 31 16:26:31 2020 -0700

    Updating client documentation for the new package update scenario and refactoring. (#47)

    * Updating client documentation for the new package update scenario and refactoring. (#47)

    Also merging in from master:
    * Adding documentation for Yocto and improved details about ADU reference client (#42)

commit 1f1c63150f9229280013030f2a7148a9ed299177
Author: Casey Irvine <44978150+cirvine-MSFT@users.noreply.github.com>
Date:   Fri Mar 27 15:34:53 2020 -0700

    Adding support for logging directory in daemon (#44)

    Added support for the standard logging directory in the ADU deamon.
    Fixed issues where we are passing the wrong cmake vars to install script.
    Build the client package seperate from the standalone exe.

commit 0d7d118cba3c174cc626db30b29637fd08fa6580
Author: Casey Irvine <44978150+cirvine-MSFT@users.noreply.github.com>
Date:   Thu Mar 26 10:40:55 2020 -0700

    Adding package generation to build. (#43)

    Generating debian package for ubuntu 18.04
    Added daemon systemd unit file.
    Added cmake options to configure daemon.
    Moved cmake options to top level cmake file.
    Added building package to the azure pipelines.

commit bd42555d0dfc0cbd3c23f4fe541d478f6ae3fdcc
Author: Casey Irvine <44978150+cirvine-MSFT@users.noreply.github.com>
Date:   Fri Mar 20 18:20:39 2020 -0700

    Merge latest dev/adu-core-v2 into dev/package-update (#40)

    * Refactor for V2 ADU Core interface. (#30)

    Added ADU Core V2 interface implementation behind ifdefs.
    Refactored platform layer and content handler code.
    Moved some common code into libraries.
    Renamed files to be consistent.

    * Finishing ADU Core V2 PnP interface implementation (#38)

    Some small refactors.
    Addressed TODOs.
    Added exceptions.
    Moved hash functions into a library.

    * Fixing previous PR comments and adding UTs (#39)

    * Merging latest master into dev/adu-core-v2 branch. (#41)

    * Update README.md (#29)

    Added CELA disclaimer per Vincent and Karthik

    * Adding dev and feature branches to build. (#28)

    Co-authored-by: tejasp-ms <tejasp-ms@users.noreply.github.com>

    Co-authored-by: tejasp-ms <tejasp-ms@users.noreply.github.com>

commit d5d5b0870bc31fa6d8526571eb038bcaa26b47e7
Author: Casey Irvine <44978150+cirvine-MSFT@users.noreply.github.com>
Date:   Thu Mar 12 20:29:52 2020 -0700

    Refactor for V2 ADU Core interface. (#30) (#35)

    Added ADU Core V2 interface implementation behind ifdefs.
    Refactored platform layer and content handler code.
    Moved some common code into libraries.
    Renamed files to be consistent.

* Update version number
@GauravChoube
Copy link

Hi nihemstr,
I am working same concept where adding DPS feature to adu agent code same way as you explained with little minor changed.
I used x509 certificate type instead of connection string and used the IoTHubDeviceClient_LL_CreateFromDeviceAuth

I got successfully registered with DPS to IOT hub and get connect to hub, update twins properties.
But code get stuck after subscription to topic $iothub/twin/PATCH/properties/desired/#.
I have build the all on pi 4 running on Raspbian os.

Below are low please look and help me out finding root clause.

Nov 29 04:50:03 raspberrypi systemd[1]: Stopped Azure Device Update Agent daemon..
Nov 29 04:50:03 raspberrypi systemd[1]: Started Azure Device Update Agent daemon..
Nov 29 04:50:17 raspberrypi AducIotAgent[4218]: Hi This is Gaurav from agentEnter into test function sucessfully2021-11-29T04:50:03.1160Z [I] Agent (linux; 0.6.0-public-preview) starting. [main]
Nov 29 04:50:17 raspberrypi AducIotAgent[4218]: 2021-11-29T04:50:03.1160Z [I] Git Info: main:743bb72 [main]
Nov 29 04:50:17 raspberrypi AducIotAgent[4218]: 2021-11-29T04:50:03.1160Z [I] Agent built with handlers: microsoft/swupdate. [main]
Nov 29 04:50:17 raspberrypi AducIotAgent[4218]: inside AllocateDeviceClientHandle
Nov 29 04:50:17 raspberrypi AducIotAgent[4218]: Provisioning API Version: 1.7.0
Nov 29 04:50:17 raspberrypi AducIotAgent[4218]: Info: Initiating DPS client to retrieve IoT Hub connection information
Nov 29 04:50:17 raspberrypi AducIotAgent[4218]: Provisioning Status: 0
Nov 29 04:50:17 raspberrypi AducIotAgent[4218]: Provisioning Status: 2
Nov 29 04:50:17 raspberrypi AducIotAgent[4218]: Registration Information received from service: devmgmtiothub.azure-devices.net!
Nov 29 04:50:17 raspberrypi AducIotAgent[4218]: Info: Provisioning callback indicates success.  iothubUri=devmgmtiothub.azure-devices.net, deviceId=dev_iot_001
Nov 29 04:50:17 raspberrypi AducIotAgent[4218]: Info: DPS successfully registered.  Continuing on to creation of IoTHub device client handle.
Nov 29 04:50:17 raspberrypi AducIotAgent[4218]: 2021-11-29T04:50:14.7812Z [I] Initalizing PnP components. [ADUC_PnP_Components_Create]
Nov 29 04:50:17 raspberrypi AducIotAgent[4218]: 2021-11-29T04:50:14.7813Z [I] ADUC agent started. Using IoT Hub Client SDK 1.7.0 [AzureDeviceUpdateCoreInterface_Create]
Nov 29 04:50:17 raspberrypi AducIotAgent[4218]: 2021-11-29T04:50:14.7813Z [I] Calling ADUC_Register [ADUC_MethodCall_Register]
Nov 29 04:50:17 raspberrypi AducIotAgent[4218]: 2021-11-29T04:50:14.7814Z [I] IoTHub Device Twin callback registered. [ADUC_DeviceClient_Create]
Nov 29 04:50:17 raspberrypi AducIotAgent[4218]: 2021-11-29T04:50:14.7819Z [W] Failed to pass connection string to DO, error: -1 [StartupAgent]
Nov 29 04:50:17 raspberrypi AducIotAgent[4218]: 2021-11-29T04:50:14.7819Z [I] Agent running. [main]
Nov 29 04:50:17 raspberrypi AducIotAgent[4218]: -> 04:50:15 CONNECT | VER: 4 | KEEPALIVE: 240 | FLAGS: 128 | USERNAME: devmgmtiothub.azure-devices.net/dev_iot_001/?api-version=2020-09-30&DeviceClientType=iothubclient%2f1.7.0%20(native%3b%20Linux%3b%20armv7l)&model-id=dtmi%3aAzureDeviceUpdate%3b1 | CLEAN: 0
Nov 29 04:50:17 raspberrypi AducIotAgent[4218]: <- 04:50:16 CONNACK | SESSION_PRESENT: true | RETURN_CODE: 0x0
Nov 29 04:50:17 raspberrypi AducIotAgent[4218]: 2021-11-29T04:50:16.2355Z [D] IotHub connection status: 0, reason:6 [ADUC_ConnectionStatus_Callback]
Nov 29 04:50:17 raspberrypi AducIotAgent[4218]: -> 04:50:16 SUBSCRIBE | PACKET_ID: 2 | TOPIC_NAME: $iothub/twin/res/# | QOS: 0
Nov 29 04:50:17 raspberrypi AducIotAgent[4218]: <- 04:50:16 SUBACK | PACKET_ID: 2 | RETURN_CODE: 0
Nov 29 04:50:17 raspberrypi AducIotAgent[4218]: -> 04:50:16 PUBLISH | IS_DUP: false | RETAIN: 0 | QOS: DELIVER_AT_MOST_ONCE | TOPIC_NAME: $iothub/twin/GET/?$rid=3
Nov 29 04:50:17 raspberrypi AducIotAgent[4218]: <- 04:50:17 PUBLISH | IS_DUP: false | RETAIN: 0 | QOS: DELIVER_AT_MOST_ONCE | TOPIC_NAME: $iothub/twin/res/200/?$rid=3 | PAYLOAD_LEN: 537
Nov 29 04:50:17 raspberrypi AducIotAgent[4218]: 2021-11-29T04:50:17.0376Z [I] Processing existing Device Twin data after agent started. [ADUC_PnPDeviceTwin_Callback]
Nov 29 04:50:17 raspberrypi AducIotAgent[4218]: 2021-11-29T04:50:17.0376Z [D] Notifies components that all callback are subscribed. [ADUC_PnPDeviceTwin_Callback]
Nov 29 04:50:17 raspberrypi AducIotAgent[4218]: 2021-11-29T04:50:17.0377Z [I] DeviceInformation component is ready - reporting properties [DeviceInfoInterface_Connected]
Nov 29 04:50:17 raspberrypi AducIotAgent[4218]: 2021-11-29T04:50:17.0379Z [I] Property manufacturer changed to Contoso [RefreshDeviceInfoInterfaceData]
Nov 29 04:50:17 raspberrypi AducIotAgent[4218]: 2021-11-29T04:50:17.0380Z [I] Property model changed to Virtual-Machine [RefreshDeviceInfoInterfaceData]
Nov 29 04:50:17 raspberrypi AducIotAgent[4218]: 2021-11-29T04:50:17.0380Z [I] Property osName changed to Linux [RefreshDeviceInfoInterfaceData]
Nov 29 04:50:17 raspberrypi AducIotAgent[4218]: 2021-11-29T04:50:17.0381Z [I] Property swVersion changed to 5.10.17-v7l- [RefreshDeviceInfoInterfaceData]
Nov 29 04:50:17 raspberrypi AducIotAgent[4218]: 2021-11-29T04:50:17.0382Z [I] Property processorArchitecture changed to armv7l [RefreshDeviceInfoInterfaceData]
Nov 29 04:50:17 raspberrypi AducIotAgent[4218]: 2021-11-29T04:50:17.0628Z [I] Property processorManufacturer changed to ARM [RefreshDeviceInfoInterfaceData]
Nov 29 04:50:17 raspberrypi AducIotAgent[4218]: 2021-11-29T04:50:17.0630Z [I] Property totalMemory changed to 3919128 [RefreshDeviceInfoInterfaceData]
Nov 29 04:50:17 raspberrypi AducIotAgent[4218]: 2021-11-29T04:50:17.0631Z [I] Property totalStorage changed to 2405632 [RefreshDeviceInfoInterfaceData]
Nov 29 04:50:17 raspberrypi AducIotAgent[4218]: 2021-11-29T04:50:17.0633Z [I] No update content. Reporting Idle state. [ADUC_Workflow_HandleStartupWorkflowData]
Nov 29 04:50:17 raspberrypi AducIotAgent[4218]: 2021-11-29T04:50:17.0634Z [I] Setting UpdateState to Idle [ADUC_SetUpdateStateHelper]
Nov 29 04:50:17 raspberrypi AducIotAgent[4218]: 2021-11-29T04:50:17.0634Z [I] Reporting state: 0, Idle (0); HTTP 200; result 1, 0 [AzureDeviceUpdateCoreInterface_ReportStateAndResultAsync]
Nov 29 04:50:17 raspberrypi AducIotAgent[4218]: 2021-11-29T04:50:17.0635Z [I] UpdateAction: Idle. WorkflowId: 211129045017 [ADUC_MethodCall_Idle]
Nov 29 04:50:17 raspberrypi AducIotAgent[4218]: 2021-11-29T04:50:17.0636Z [I] Calling IdleCallback [ADUC_MethodCall_Idle]
Nov 29 04:50:17 raspberrypi AducIotAgent[4218]: 2021-11-29T04:50:17.0636Z [I] Now idle. workflowId: 211129045017 [Idle]
Nov 29 04:50:17 raspberrypi AducIotAgent[4218]: -> 04:50:17 SUBSCRIBE | PACKET_ID: 4 | TOPIC_NAME: $iothub/twin/PATCH/properties/desired/# | QOS: 0

@nihemstr
Copy link
Contributor

Hey @GauravChoube I'm not sure how to debug the issue with the topic. I can ping the service, but it looks like we resolved the initial issue. If you're still working on this implementation, please feel free to create a new issue and I can pass it along to my service side counterparts to take a deeper dive.

Thanks!

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

4 participants