@@ -40,6 +40,7 @@ public Inventory(IPAMSecretResolver resolver)
4040 _resolver = resolver ;
4141 }
4242
43+ private PaloAltoClient _client ;
4344 private string ServerPassword { get ; set ; }
4445 private string ServerUserName { get ; set ; }
4546
@@ -79,25 +80,24 @@ private JobResult PerformInventory(InventoryJobConfiguration config, SubmitInven
7980 config . JobHistoryId , ServerUserName , ServerPassword ) ;
8081 if ( ! valid ) return result ;
8182
82- _logger . LogTrace ( "Store Properties are Valid" ) ;
83- _logger . LogTrace ( $ "Inventory Config { JsonConvert . SerializeObject ( config ) } ") ;
84- _logger . LogTrace (
85- $ "Client Machine: { config . CertificateStoreDetails . ClientMachine } ApiKey: { config . ServerPassword } ") ;
86-
8783 //Get the list of certificates and Trusted Roots
88- var client =
84+ _client =
8985 new PaloAltoClient ( config . CertificateStoreDetails . ClientMachine ,
9086 ServerUserName , ServerPassword ) ; //Api base URL Plus Key
87+
88+ _logger . LogTrace ( "Store Properties are Valid" ) ;
89+ _logger . LogTrace ( $ "Inventory Config { _client . MaskSensitiveData ( JsonConvert . SerializeObject ( config ) ) } ") ;
90+
9191 _logger . LogTrace ( "Inventory Palo Alto Client Created" ) ;
9292
9393 //Change the path if you are pointed to a Panorama Device
94- var rawCertificatesResult = client . GetCertificateList ( $ "{ config . CertificateStoreDetails . StorePath } /certificate/entry") . Result ;
94+ var rawCertificatesResult = _client . GetCertificateList ( $ "{ config . CertificateStoreDetails . StorePath } /certificate/entry") . Result ;
9595
9696 var certificatesResult =
9797 rawCertificatesResult . CertificateResult . Entry . FindAll ( c => c . PublicKey != null ) ;
9898 LogResponse ( certificatesResult ) ; //Trace Write Certificate List Response from Palo Alto
9999
100- var trustedRootPayload = client . GetTrustedRootList ( ) . Result ;
100+ var trustedRootPayload = _client . GetTrustedRootList ( ) . Result ;
101101 LogResponse ( trustedRootPayload ) ; //Trace Write Trusted Cert List Response from Palo Alto
102102
103103 var warningFlag = false ;
@@ -133,7 +133,7 @@ private JobResult PerformInventory(InventoryJobConfiguration config, SubmitInven
133133 try
134134 {
135135 _logger . LogTrace ( $ "Building Trusted Root Inventory Item Alias: { trustedRootCert . Name } ") ;
136- var certificatePem = client . GetCertificateByName ( trustedRootCert . Name ) ;
136+ var certificatePem = _client . GetCertificateByName ( trustedRootCert . Name ) ;
137137 _logger . LogTrace ( $ "Certificate String Back From Palo Pem: { certificatePem . Result } ") ;
138138 var bytes = Encoding . ASCII . GetBytes ( certificatePem . Result ) ;
139139 var cert = new X509Certificate2 ( bytes ) ;
@@ -219,4 +219,4 @@ protected virtual CurrentInventoryItem BuildInventoryItem(string alias, string c
219219 }
220220 }
221221 }
222- }
222+ }
0 commit comments