@@ -188,21 +188,25 @@ def main(in_args):
188
188
189
189
# save device cert
190
190
dev = device_cert .public_bytes (serialization .Encoding .PEM )
191
- write_file (args .path , args .fileprefix + common_name + "_crt.pem" , dev )
192
191
if args .embed_save :
193
192
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 )
194
195
195
196
# save public key
196
197
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 )
198
200
199
201
# If we generated a local private key, save that to disk too, so it can be installed to the
200
202
# device.
201
203
if local_priv_key is not None :
202
204
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 )
204
205
if args .embed_save :
205
206
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
+
206
210
207
211
if args .embed_save :
208
212
# save the AWS CA cert
0 commit comments