Skip to content

fix: reusing certificate was failing - #100

Merged
maxd-nordic merged 1 commit into
mainfrom
maxd/fix-cert-reuse
Oct 21, 2026
Merged

maxd-nordic merged 1 commit into
mainfrom
maxd/fix-cert-reuse

Conversation

@maxd-nordic

@maxd-nordic maxd-nordic commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Note

Low Risk
Small CSV serialization fix with a regression test; no auth or device-write behavior changes beyond fixing the reuse path.

Overview
Fixes onboarding CSV generation when reusing credentials loaded from disk (--path with existing *_crt.pem / *_prv.pem). Those certs are read as strings, but save_onboarding_csv always did str(dev, encoding=...), which breaks for str inputs and caused the “reusing certificate” failure.

The helper now uses the cert text as-is when dev is already a str, and only decodes with full_encoding when it is bytes. A new installer test runs save-then-reuse and asserts the onboarding CSV contains a valid PEM cert.

Reviewed by Cursor Bugbot for commit 1bccbc0. Bugbot is set up for automated code reviews on this repo. Configure here.

Signed-off-by: Maximilian Deubel <maximilian.deubel@nordicsemi.no>
@maxd-nordic
maxd-nordic requested a balanced review from Copilot October 21, 2026 10:28
@maxd-nordic
maxd-nordic merged commit 14fa4e1 into main Oct 21, 2026
7 checks passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The regression test’s serial fake rejects the private-key write needed to reach CSV generation.

1 open issue
What changed in this PR

Fixes onboarding CSV generation when reusing certificates loaded from disk.

Changes:

  • Preserves string certificates while retaining decoding for byte inputs.
  • Adds a save-then-reuse regression test.
File Description
tests/​test_device_credentials_installer.py Adds coverage for CSV generation with reused credentials.
src/​nrfcloud_utils/​cli_helpers.py Handles string and byte certificates during CSV serialization.

Review effort: Balanced

Comment on lines +115 to +116
device_credentials_installer.main(
f"{base} --id-str {dev_id} --path {tmp_dir}{os.sep} --csv {csv_file}".split())
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

Successfully merging this pull request may close these issues.

2 participants