@@ -67,18 +67,17 @@ pub enum TEdgeCertCli {
6767 #[ clap( long = "csr-path" , global = true , value_hint = ValueHint :: FilePath ) ]
6868 csr_path : Option < Utf8PathBuf > ,
6969
70- /// Force the renewal of self-signed certificates as self-signed
70+ /// Certificate Authority (CA) used to renew the certificate
7171 ///
72- /// This can be used to bypass the default behavior
73- /// which is to forward the renewal request to the cloud CA
74- /// even if the current certificate has not been signed by this CA.
72+ /// Cumulocity CA is currently the only supported one and this is the default,
73+ /// even if the current certificate has not been signed by Cumulocity.
7574 /// In most cases, the default behavior is what you want:
7675 /// substitute a proper CA-signed certificate for a self-signed certificate.
7776 ///
7877 /// However, if this is not the case, or if the cloud endpoint doesn't provide a CA:
79- /// use `--self-signed` to get a renewed self-signed certificate.
80- #[ clap( long = "self-signed " , default_value_t = false ) ]
81- self_signed_only : bool ,
78+ /// use `--ca self-signed` to get a renewed self-signed certificate.
79+ #[ clap( long = "ca " , default_value_t = CA :: C8y ) ]
80+ ca : CA ,
8281
8382 #[ clap( subcommand) ]
8483 cloud : Option < CloudArg > ,
@@ -132,6 +131,15 @@ pub enum TEdgeCertCli {
132131 Download ( DownloadCertCli ) ,
133132}
134133
134+ #[ derive( clap:: ValueEnum , Clone , Debug , Eq , PartialEq , strum_macros:: Display ) ]
135+ pub enum CA {
136+ #[ strum( serialize = "self-signed" ) ]
137+ SelfSigned ,
138+
139+ #[ strum( serialize = "c8y" ) ]
140+ C8y ,
141+ }
142+
135143impl BuildCommand for TEdgeCertCli {
136144 fn build_command (
137145 self ,
@@ -287,7 +295,7 @@ impl BuildCommand for TEdgeCertCli {
287295 TEdgeCertCli :: Renew {
288296 csr_path,
289297 cloud,
290- self_signed_only ,
298+ ca ,
291299 } => {
292300 let cloud: Option < Cloud > = cloud. map ( <_ >:: try_into) . transpose ( ) ?;
293301 let cert_path = config. device_cert_path ( cloud. as_ref ( ) ) ?. to_owned ( ) ;
@@ -310,15 +318,15 @@ impl BuildCommand for TEdgeCertCli {
310318 }
311319 } ;
312320
313- if is_self_signed && self_signed_only {
321+ if is_self_signed && ca == CA :: SelfSigned {
314322 let cmd = RenewCertCmd {
315323 cert_path,
316324 new_cert_path,
317325 key_path,
318326 csr_template,
319327 } ;
320328 cmd. into_boxed ( )
321- } else if self_signed_only {
329+ } else if ca == CA :: SelfSigned {
322330 return Err (
323331 anyhow ! ( "Cannot renew certificate with `--self-signed`: {cert_path} is not self-signed" ) . into ( )
324332 ) ;
0 commit comments