@@ -158,17 +158,34 @@ public JobResult ProcessJob(ManagementJobConfiguration config)
158158 // Retrieve management config from Command
159159 _logger . LogDebug ( $ "Management Config { JsonConvert . SerializeObject ( config ) } ") ;
160160 _logger . LogDebug ( $ "Client Machine: { config . CertificateStoreDetails . ClientMachine } ") ;
161+
162+ // Get needed information from config
163+ string alias = config . JobCertificate . Alias ;
164+ string certBase64Der = config . JobCertificate . Contents ;
161165
166+ // Prevent removal of client certs; Client certs may be removed as part of a future update
167+ if ( IsCACertificate ( certBase64Der ) )
168+ {
169+ _logger . LogInformation ( "Certificate is a CA trust cert. Proceeding with Remove operation..." ) ;
170+ }
171+ else
172+ {
173+ _logger . LogWarning ( "Certificate is an end-entity cert. Unable to remove this certificate type from a device." ) ;
174+ return new JobResult ( )
175+ {
176+ Result = OrchestratorJobStatusJobResult . Warning ,
177+ JobHistoryId = config . JobHistoryId ,
178+ FailureMessage = $ "UNSUPPORTED OPERATION --- This certificate is an end-entity cert. Unable to remove end-entity certificates from a device."
179+ } ;
180+ }
181+
162182 // Create client to connect to device
163183 _logger . LogTrace ( "Creating Api Rest Client..." ) ;
164184 var client = new AxisHttpClient ( config , config . CertificateStoreDetails ) ;
165185 _logger . LogTrace ( "Api Rest Client Created..." ) ;
166186
167- // Get needed information from config
168- string alias = config . JobCertificate . Alias ;
169-
170187 // Remove certificate with alias from the device
171- client . RemoveCertificate ( alias ) ;
188+ client . RemoveCACertificate ( alias ) ;
172189
173190 break ;
174191 }
0 commit comments