@@ -352,6 +352,35 @@ private X509Certificate2Collection GetCertificateEntry(string path)
352
352
return c . ToX509Certificate2Collection ( ) ;
353
353
}
354
354
355
+ public List < F5SSLProfile > GetSSLProfiles ( int pageSize )
356
+ {
357
+ LogHandlerCommon . MethodEntry ( logger , CertificateStore , "GetSSLProfiles" ) ;
358
+ string partition = CertificateStore . StorePath ;
359
+ string query = $ "/mgmt/tm/ltm/profile/client-ssl?$top={ pageSize } &$skip=0";
360
+ F5PagedSSLProfiles pagedProfiles = REST . Get < F5PagedSSLProfiles > ( query ) ;
361
+ List < F5SSLProfile > profiles = new List < F5SSLProfile > ( ) ;
362
+
363
+ if ( pagedProfiles . totalItems == 0 || pagedProfiles . items ? . Length == 0 )
364
+ {
365
+ return profiles ;
366
+ }
367
+
368
+ for ( int i = pagedProfiles . pageIndex ; i <= pagedProfiles . totalPages ; i ++ )
369
+ {
370
+ profiles . AddRange ( pagedProfiles . items ) ;
371
+
372
+ // The current paged profile will contain a link to the next set, unless the end has been reached
373
+ if ( string . IsNullOrEmpty ( pagedProfiles . nextLink ) ) { break ; }
374
+
375
+ // Get the next page of profiles
376
+ query = pagedProfiles . nextLink . Replace ( "https://localhost" , "" ) ;
377
+ pagedProfiles = REST . Get < F5PagedSSLProfiles > ( query ) ;
378
+ }
379
+
380
+ LogHandlerCommon . MethodExit ( logger , CertificateStore , "GetCertificateEntries" ) ;
381
+ return profiles ;
382
+ }
383
+
355
384
private void SetItemStatus ( CurrentInventoryItem agentInventoryItem )
356
385
{
357
386
LogHandlerCommon . MethodEntry ( logger , CertificateStore , "SetItemStatus" ) ;
@@ -611,67 +640,67 @@ private List<X509Certificate2> ReorderPEMLIst(List<X509Certificate2> certList)
611
640
// WebServer
612
641
#endregion
613
642
614
- #region SSL Profiles
643
+ #region SSL Certificates
615
644
616
- public List < CurrentInventoryItem > GetSSLProfiles ( int pageSize )
645
+ public List < CurrentInventoryItem > GetCertificateEntries ( int pageSize )
617
646
{
618
- LogHandlerCommon . MethodEntry ( logger , CertificateStore , "GetSSLProfiles " ) ;
647
+ LogHandlerCommon . MethodEntry ( logger , CertificateStore , "GetCertificateEntries " ) ;
619
648
string partition = CertificateStore . StorePath ;
620
649
string query = $ "/mgmt/tm/sys/file/ssl-cert?$filter=partition+eq+{ partition } &$select=name,keyType,isBundle&$top={ pageSize } &$skip=0";
621
- F5PagedSSLProfiles pagedProfiles = REST . Get < F5PagedSSLProfiles > ( query ) ;
622
- List < F5SSLProfile > profiles = new List < F5SSLProfile > ( ) ;
650
+ F5PagedSSLCertificates pagedCertificates = REST . Get < F5PagedSSLCertificates > ( query ) ;
651
+ List < F5SSLCertificate > certificates = new List < F5SSLCertificate > ( ) ;
623
652
List < CurrentInventoryItem > inventory = new List < CurrentInventoryItem > ( ) ;
624
653
625
- if ( pagedProfiles . totalItems == 0 || pagedProfiles . items ? . Length == 0 )
654
+ if ( pagedCertificates . totalItems == 0 || pagedCertificates . items ? . Length == 0 )
626
655
{
627
- LogHandlerCommon . Trace ( logger , CertificateStore , $ "No SSL profiles found in partition '{ partition } '") ;
628
- LogHandlerCommon . MethodExit ( logger , CertificateStore , "GetSSLProfiles " ) ;
656
+ LogHandlerCommon . Trace ( logger , CertificateStore , $ "No SSL certificates found in partition '{ partition } '") ;
657
+ LogHandlerCommon . MethodExit ( logger , CertificateStore , "GetCertificateEntries " ) ;
629
658
return inventory ;
630
659
}
631
660
else
632
661
{
633
- LogHandlerCommon . Trace ( logger , CertificateStore , $ "Compiling { pagedProfiles . totalPages } pages containing { pagedProfiles . totalItems } total inventory entries") ;
662
+ LogHandlerCommon . Trace ( logger , CertificateStore , $ "Compiling { pagedCertificates . totalPages } pages containing { pagedCertificates . totalItems } total inventory entries") ;
634
663
}
635
664
636
- // Collected all of the profile entry names
637
- for ( int i = pagedProfiles . pageIndex ; i <= pagedProfiles . totalPages ; i ++ )
665
+ // Collected all of the certificate entry names
666
+ for ( int i = pagedCertificates . pageIndex ; i <= pagedCertificates . totalPages ; i ++ )
638
667
{
639
- profiles . AddRange ( pagedProfiles . items ) ;
668
+ certificates . AddRange ( pagedCertificates . items ) ;
640
669
641
- // The current paged profile will contain a link to the next set, unless the end has been reached
642
- if ( string . IsNullOrEmpty ( pagedProfiles . nextLink ) ) { break ; }
670
+ // The current paged certificate list will contain a link to the next set, unless the end has been reached
671
+ if ( string . IsNullOrEmpty ( pagedCertificates . nextLink ) ) { break ; }
643
672
644
- // Get the next page of profiles
645
- query = pagedProfiles . nextLink . Replace ( "https://localhost" , "" ) ;
646
- pagedProfiles = REST . Get < F5PagedSSLProfiles > ( query ) ;
673
+ // Get the next page of certificates
674
+ query = pagedCertificates . nextLink . Replace ( "https://localhost" , "" ) ;
675
+ pagedCertificates = REST . Get < F5PagedSSLCertificates > ( query ) ;
647
676
}
648
677
649
678
// Compile the entries into inventory items
650
- for ( int i = 0 ; i < profiles . Count ; i ++ )
679
+ for ( int i = 0 ; i < certificates . Count ; i ++ )
651
680
{
652
681
try
653
682
{
654
- LogHandlerCommon . Trace ( logger , CertificateStore , $ "Processing alias { profiles [ i ] . name } ") ;
683
+ LogHandlerCommon . Trace ( logger , CertificateStore , $ "Processing alias { certificates [ i ] . name } ") ;
655
684
// Exclude 'ca-bundle.crt' as that can only be managed by F5
656
- if ( profiles [ i ] . name . Equals ( "ca-bundle.crt" , StringComparison . OrdinalIgnoreCase )
657
- || profiles [ i ] . name . Equals ( "f5-ca-bundle.crt" , StringComparison . OrdinalIgnoreCase ) )
685
+ if ( certificates [ i ] . name . Equals ( "ca-bundle.crt" , StringComparison . OrdinalIgnoreCase )
686
+ || certificates [ i ] . name . Equals ( "f5-ca-bundle.crt" , StringComparison . OrdinalIgnoreCase ) )
658
687
{
659
- LogHandlerCommon . Trace ( logger , CertificateStore , $ "Skipping '{ profiles [ i ] . name } ' because it is managed by F5") ;
688
+ LogHandlerCommon . Trace ( logger , CertificateStore , $ "Skipping '{ certificates [ i ] . name } ' because it is managed by F5") ;
660
689
continue ;
661
690
}
662
- inventory . Add ( GetInventoryItem ( partition , profiles [ i ] . name , true ) ) ;
691
+ inventory . Add ( GetInventoryItem ( partition , certificates [ i ] . name , true ) ) ;
663
692
}
664
693
catch ( Exception ex )
665
694
{
666
- LogHandlerCommon . Error ( logger , CertificateStore , ExceptionHandler . FlattenExceptionMessages ( ex , $ "Unable to process inventory item { profiles [ i ] . name } .") ) ;
695
+ LogHandlerCommon . Error ( logger , CertificateStore , ExceptionHandler . FlattenExceptionMessages ( ex , $ "Unable to process inventory item { certificates [ i ] . name } .") ) ;
667
696
}
668
697
}
669
698
670
- LogHandlerCommon . MethodExit ( logger , CertificateStore , "GetSSLProfiles " ) ;
699
+ LogHandlerCommon . MethodExit ( logger , CertificateStore , "GetCertificateEntries " ) ;
671
700
return inventory ;
672
701
}
673
702
674
- // SSL Profiles
703
+ // SSL Certificates
675
704
#endregion
676
705
677
706
#region Auth & Version
0 commit comments