Skip to content

tedge cert renew c8y does not return non-zero exit code if EST service is not available #3524

@reubenmiller

Description

@reubenmiller

Describe the bug

A failed cert renewal using the Cumulocity CA feature does not result in a non-zero exit code which makes more difficult to use it in a script to handle the renewal.

Below shows an example showing the error printed to the console, but the exit code is still zero.

$ tedge cert renew c8y
error: The device certificate cannot be renewed from http://127.0.0.1:8001/c8y/.well-known/est/simplereenroll:
        404 Not Found <html>
<head><title>404 Not Found</title></head>
<body>
<center><h1>404 Not Found</h1></center>
<hr><center>openresty</center>
</body>
</html>
$ echo $?
0

To Reproduce

  1. Configure thin-edge.io with a tenant which does not have the Cumulocity certificate-authority feature enabled

  2. On board the device with a self-signed certificate

  3. Try to renew the certificate (using the certificate-authority)

    tedge cert renew c8y

Expected behavior

The tedge cert renew c8y command should exit with a non-zero exit code if the certificate renewal was not successful.

This would enable the following logic in a shell script:

#!/bin/sh
if ! tedge cert renew c8y; then
  echo "Warning: failed to renew certificate"
fi

Screenshots

Environment (please complete the following information):

Property Value
OS [incl. version] Debian GNU/Linux 12 (bookworm)
Hardware [incl. revision] unknown
System-Architecture Linux d82e7bd77e49 6.8.0-39-generic #39-Ubuntu SMP PREEMPT_DYNAMIC Sat Jul 6 02:50:39 UTC 2024 aarch64 GNU/Linux
thin-edge.io version tedge 1.4.3~391+g945be87

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtheme:certificatesTheme: Device certificate topics

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions