@@ -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,26 @@ private JobResult PerformInventory(InventoryJobConfiguration config, SubmitInven
7980 config . JobHistoryId , ServerUserName , ServerPassword ) ;
8081 if ( ! valid ) return result ;
8182
83+ //Get the list of certificates and Trusted Roots
84+ _client =
85+ new PaloAltoClient ( config . CertificateStoreDetails . ClientMachine ,
86+ ServerUserName , ServerPassword ) ; //Api base URL Plus Key
87+
8288 _logger . LogTrace ( "Store Properties are Valid" ) ;
83- _logger . LogTrace ( $ "Inventory Config { JsonConvert . SerializeObject ( config ) } ") ;
89+ _logger . LogTrace ( $ "Inventory Config { _client . MaskSensitiveData ( JsonConvert . SerializeObject ( config ) ) } ") ;
8490 _logger . LogTrace (
8591 $ "Client Machine: { config . CertificateStoreDetails . ClientMachine } ApiKey: { config . ServerPassword } ") ;
8692
87- //Get the list of certificates and Trusted Roots
88- var client =
89- new PaloAltoClient ( config . CertificateStoreDetails . ClientMachine ,
90- ServerUserName , ServerPassword ) ; //Api base URL Plus Key
9193 _logger . LogTrace ( "Inventory Palo Alto Client Created" ) ;
9294
9395 //Change the path if you are pointed to a Panorama Device
94- var rawCertificatesResult = client . GetCertificateList ( $ "{ config . CertificateStoreDetails . StorePath } /certificate/entry") . Result ;
96+ var rawCertificatesResult = _client . GetCertificateList ( $ "{ config . CertificateStoreDetails . StorePath } /certificate/entry") . Result ;
9597
9698 var certificatesResult =
9799 rawCertificatesResult . CertificateResult . Entry . FindAll ( c => c . PublicKey != null ) ;
98100 LogResponse ( certificatesResult ) ; //Trace Write Certificate List Response from Palo Alto
99101
100- var trustedRootPayload = client . GetTrustedRootList ( ) . Result ;
102+ var trustedRootPayload = _client . GetTrustedRootList ( ) . Result ;
101103 LogResponse ( trustedRootPayload ) ; //Trace Write Trusted Cert List Response from Palo Alto
102104
103105 var warningFlag = false ;
@@ -133,7 +135,7 @@ private JobResult PerformInventory(InventoryJobConfiguration config, SubmitInven
133135 try
134136 {
135137 _logger . LogTrace ( $ "Building Trusted Root Inventory Item Alias: { trustedRootCert . Name } ") ;
136- var certificatePem = client . GetCertificateByName ( trustedRootCert . Name ) ;
138+ var certificatePem = _client . GetCertificateByName ( trustedRootCert . Name ) ;
137139 _logger . LogTrace ( $ "Certificate String Back From Palo Pem: { certificatePem . Result } ") ;
138140 var bytes = Encoding . ASCII . GetBytes ( certificatePem . Result ) ;
139141 var cert = new X509Certificate2 ( bytes ) ;
0 commit comments