Skip to content

sm-plugin fails to download c8y resource when local proxy is using cert based authentication #3212

@reubenmiller

Description

@reubenmiller

Describe the bug

The thin-edge.io software management plugin interface fails to download files from the Cumulocity Local Proxy service if local certificate-based authentication is being used.

The error appears when thin-edge.io tries to download the artifact from the Cumulocity Local Proxy (if the artifact's url is hosted in Cumulocity), before calling the sm-plugin install subcommand. Below shows the error in the tedge-agent logs:

Oct 29 10:16:24 rpi5-d83add9f145a tedge-agent[871]: 2024-10-29T10:16:24.153856163Z ERROR plugin_sm::plugin: Download error: DownloadError {
Oct 29 10:16:24 rpi5-d83add9f145a tedge-agent[871]:     reason: "error sending request for url (https://rpi5-d83add9f145a:8001/c8y/inventory/binaries/40663602): error trying to connect: received corrupt message of type InvalidContentType",
Oct 29 10:16:24 rpi5-d83add9f145a tedge-agent[871]:     url: "https://rpi5-d83add9f145a:8001/c8y/inventory/binaries/40663602",
Oct 29 10:16:24 rpi5-d83add9f145a tedge-agent[871]:     source_err: "error trying to connect: received corrupt message of type InvalidContentType",
Oct 29 10:16:24 rpi5-d83add9f145a tedge-agent[871]: }

Looking at the code, it seems that the tedge.toml setting; c8y.proxy.key_path, c8y.proxy.cert_path and c8y.proxy.ca_path are ignored, as shown in the following code (though please verify if this link is correct).

let mut client_builder = cloud_root_certs.client_builder();
if let Some(identity) = identity {

To Reproduce

  1. Configure thin-edge.io to cert-based authentication for local services such as
  2. Create a software and version in the Cumulocity Software repository
  3. Install software with uses the url field (to download the artifact from the platform)

Expected behavior

  • If the Cumulocity Local Proxy is configured to use cert-based authentication (for local connections), then any thin-edge.io component which uses it should use the configured client certificates

Screenshots

Environment (please complete the following information):

  • OS [incl. version]: any
  • Hardware [incl. revision]: any
  • System-Architecture [e.g. result of "uname -a"]: any
  • thin-edge.io version [e.g. 0.1.0]: 1.3.1

Additional context

tedge-agent logs

Oct 29 10:16:22 rpi5-d83add9f145a sudo[9460]:    tedge : PWD=/ ; USER=root ; COMMAND=/etc/tedge/sm-plugins/container-group list
Oct 29 10:16:22 rpi5-d83add9f145a tedge-agent[871]: 2024-10-29T10:16:22.352849542Z  INFO tedge_agent::operation_workflows::actor: software_update operation executing: waiting for sub-operation completion
Oct 29 10:16:22 rpi5-d83add9f145a sudo[9460]: pam_unix(sudo:session): session opened for user root(uid=0) by (uid=999)
Oct 29 10:16:22 rpi5-d83add9f145a sudo[9460]: pam_unix(sudo:session): session closed for user root
Oct 29 10:16:22 rpi5-d83add9f145a tedge-agent[871]: 2024-10-29T10:16:22.633820361Z  INFO plugin_sm::plugin_manager: Plugin activated: /etc/tedge/sm-plugins/container-group
Oct 29 10:16:22 rpi5-d83add9f145a sudo[9596]:    tedge : PWD=/ ; USER=root ; COMMAND=/etc/tedge/sm-plugins/container list
Oct 29 10:16:22 rpi5-d83add9f145a sudo[9596]: pam_unix(sudo:session): session opened for user root(uid=0) by (uid=999)
Oct 29 10:16:22 rpi5-d83add9f145a sudo[9596]: pam_unix(sudo:session): session closed for user root
Oct 29 10:16:22 rpi5-d83add9f145a tedge-agent[871]: 2024-10-29T10:16:22.671496975Z  INFO plugin_sm::plugin_manager: Plugin activated: /etc/tedge/sm-plugins/container
Oct 29 10:16:22 rpi5-d83add9f145a sudo[9620]:    tedge : PWD=/ ; USER=root ; COMMAND=/etc/tedge/sm-plugins/apt list
Oct 29 10:16:22 rpi5-d83add9f145a sudo[9620]: pam_unix(sudo:session): session opened for user root(uid=0) by (uid=999)
Oct 29 10:16:22 rpi5-d83add9f145a sudo[9620]: pam_unix(sudo:session): session closed for user root
Oct 29 10:16:22 rpi5-d83add9f145a tedge-agent[871]: 2024-10-29T10:16:22.687532811Z  INFO plugin_sm::plugin_manager: Plugin activated: /etc/tedge/sm-plugins/apt
Oct 29 10:16:22 rpi5-d83add9f145a sudo[9623]:    tedge : PWD=/tmp ; USER=root ; COMMAND=/etc/tedge/sm-plugins/container-group prepare
Oct 29 10:16:22 rpi5-d83add9f145a sudo[9623]: pam_unix(sudo:session): session opened for user root(uid=0) by (uid=999)
Oct 29 10:16:22 rpi5-d83add9f145a sudo[9623]: pam_unix(sudo:session): session closed for user root
Oct 29 10:16:24 rpi5-d83add9f145a tedge-agent[871]: 2024-10-29T10:16:24.153856163Z ERROR plugin_sm::plugin: Download error: DownloadError {
Oct 29 10:16:24 rpi5-d83add9f145a tedge-agent[871]:     reason: "error sending request for url (https://rpi5-d83add9f145a:8001/c8y/inventory/binaries/40663602): error trying to connect: received corrupt message of type InvalidContentType",
Oct 29 10:16:24 rpi5-d83add9f145a tedge-agent[871]:     url: "https://rpi5-d83add9f145a:8001/c8y/inventory/binaries/40663602",
Oct 29 10:16:24 rpi5-d83add9f145a tedge-agent[871]:     source_err: "error trying to connect: received corrupt message of type InvalidContentType",
Oct 29 10:16:24 rpi5-d83add9f145a tedge-agent[871]: }
Oct 29 10:16:24 rpi5-d83add9f145a sudo[9722]:    tedge : PWD=/tmp ; USER=root ; COMMAND=/etc/tedge/sm-plugins/container-group finalize
Oct 29 10:16:24 rpi5-d83add9f145a sudo[9722]: pam_unix(sudo:session): session opened for user root(uid=0) by (uid=999)
Oct 29 10:16:24 rpi5-d83add9f145a sudo[9722]: pam_unix(sudo:session): session closed for user root

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtheme:c8yTheme: Cumulocity related topics

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions