Skip to content

Commit 5ceaa46

Browse files
committed
fix: don't create extraneous files on embed save
Signed-off-by: Maximilian Deubel <[email protected]>
1 parent 9982aae commit 5ceaa46

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/nrfcloud_utils/create_device_credentials.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,21 +188,25 @@ def main(in_args):
188188

189189
# save device cert
190190
dev = device_cert.public_bytes(serialization.Encoding.PEM)
191-
write_file(args.path, args.fileprefix + common_name + "_crt.pem", dev)
192191
if args.embed_save:
193192
write_file(args.path, "client-cert.pem", embed_save_convert(dev))
193+
else:
194+
write_file(args.path, args.fileprefix + common_name + "_crt.pem", dev)
194195

195196
# save public key
196197
pub = csr.public_key().public_bytes(serialization.Encoding.PEM, serialization.PublicFormat.SubjectPublicKeyInfo)
197-
write_file(args.path, args.fileprefix + common_name + "_pub.pem", pub)
198+
if not args.embed_save:
199+
write_file(args.path, args.fileprefix + common_name + "_pub.pem", pub)
198200

199201
# If we generated a local private key, save that to disk too, so it can be installed to the
200202
# device.
201203
if local_priv_key is not None:
202204
priv = local_priv_key.private_bytes(serialization.Encoding.PEM, serialization.PrivateFormat.PKCS8, serialization.NoEncryption())
203-
write_file(args.path, args.fileprefix + common_name + "_prv.pem", priv)
204205
if args.embed_save:
205206
write_file(args.path, "private-key.pem", embed_save_convert(priv))
207+
else:
208+
write_file(args.path, args.fileprefix + common_name + "_prv.pem", priv)
209+
206210

207211
if args.embed_save:
208212
# save the AWS CA cert

0 commit comments

Comments
 (0)