@@ -33,10 +33,12 @@ public class SectigoCAPlugin : IAnyCAPlugin
3333 private SectigoConfig _config ;
3434 private readonly ILogger _logger ;
3535 private ICertificateDataReader _certificateDataReader ;
36+ private ICertificateResolver _certificateResolver ;
3637
37- public SectigoCAPlugin ( )
38+ public SectigoCAPlugin ( ICertificateResolver certResolver )
3839 {
3940 _logger = LogHandler . GetClassLogger < SectigoCAPlugin > ( ) ;
41+ _certificateResolver = certResolver ;
4042 }
4143
4244 public void Initialize ( IAnyCAPluginConfigProvider configProvider , ICertificateDataReader certificateDataReader )
@@ -88,7 +90,7 @@ public async Task<EnrollmentResult> Enroll(string csr, string subject, Dictionar
8890 department = productInfo . ProductParameters [ "Department" ] ;
8991 _logger . LogTrace ( $ "Department: { department } ") ;
9092 }
91- var client = SectigoClient . InitializeClient ( _config ) ;
93+ var client = SectigoClient . InitializeClient ( _config , _certificateResolver ) ;
9294 var fieldList = Task . Run ( async ( ) => await client . ListCustomFields ( ) ) . Result ;
9395 var allFields = fieldList . CustomFields ? . Select ( f => f ) ;
9496
@@ -370,7 +372,7 @@ public async Task<AnyCAPluginCertificate> GetSingleRecord(string caRequestID)
370372 _logger . LogTrace ( $ "Get Single Certificate Detail from Sectigo (sslId: { caRequestID } )") ;
371373 int sslId = int . Parse ( caRequestID . Split ( '-' ) [ 0 ] ) ;
372374
373- var client = SectigoClient . InitializeClient ( _config ) ;
375+ var client = SectigoClient . InitializeClient ( _config , _certificateResolver ) ;
374376 var singleCert = Task . Run ( async ( ) => await client . GetCertificate ( sslId ) ) . Result ;
375377 _logger . LogTrace ( $ "{ singleCert . CommonName } ({ singleCert . status } ) retrieved from Sectigo.") ;
376378
@@ -446,7 +448,7 @@ public async Task Ping()
446448 try
447449 {
448450 _logger . LogDebug ( "Attempting to ping Sectigo API" ) ;
449- var client = SectigoClient . InitializeClient ( _config ) ;
451+ var client = SectigoClient . InitializeClient ( _config , _certificateResolver ) ;
450452 _ = Task . Run ( async ( ) => await client . ListOrganizations ( ) ) . Result ;
451453 }
452454 catch ( Exception ex )
@@ -462,7 +464,7 @@ public async Task<int> Revoke(string caRequestID, string hexSerialNumber, uint r
462464
463465 try
464466 {
465- var client = SectigoClient . InitializeClient ( _config ) ;
467+ var client = SectigoClient . InitializeClient ( _config , _certificateResolver ) ;
466468 var response = Task . Run ( async ( ) => await client . RevokeSslCertificateById ( int . Parse ( caRequestID ) , ( int ) revocationReason , RevokeReasonToString ( revocationReason ) ) ) . Result ;
467469
468470 _logger . MethodExit ( LogLevel . Debug ) ;
@@ -501,7 +503,7 @@ public async Task Synchronize(BlockingCollection<AnyCAPluginCertificate> blockin
501503 string [ ] filterProfileIds = _config . SyncFilterProfileId . Split ( ',' ) ;
502504 filter . Add ( "sslTypeId" , filterProfileIds ) ;
503505 }
504- var client = SectigoClient . InitializeClient ( _config ) ;
506+ var client = SectigoClient . InitializeClient ( _config , _certificateResolver ) ;
505507 producerTask = client . CertificateListProducer ( certsToAdd , newCancelToken . Token , _config . PageSize , filter ) ;
506508
507509 foreach ( Certificate certToAdd in certsToAdd . GetConsumingEnumerable ( ) )
@@ -654,7 +656,7 @@ public async Task ValidateProductInfo(EnrollmentProductInfo productInfo, Diction
654656 _logger . MethodEntry ( LogLevel . Debug ) ;
655657 string rawConfig = JsonConvert . SerializeObject ( connectionInfo ) ;
656658 var parsedConfig = JsonConvert . DeserializeObject < SectigoConfig > ( rawConfig ) ;
657- SectigoClient localClient = SectigoClient . InitializeClient ( parsedConfig ) ;
659+ SectigoClient localClient = SectigoClient . InitializeClient ( parsedConfig , _certificateResolver ) ;
658660
659661 var profileList = Task . Run ( async ( ) => await localClient . ListSslProfiles ( ) ) . Result ;
660662 if ( profileList . SslProfiles . Where ( p => p . id == int . Parse ( productInfo . ProductID ) ) . Count ( ) == 0 )
@@ -667,28 +669,28 @@ public async Task ValidateProductInfo(EnrollmentProductInfo productInfo, Diction
667669
668670 private async Task < Organization > GetOrganizationAsync ( string orgName )
669671 {
670- var client = SectigoClient . InitializeClient ( _config ) ;
672+ var client = SectigoClient . InitializeClient ( _config , _certificateResolver ) ;
671673 var orgList = await client . ListOrganizations ( ) ;
672674 return orgList . Organizations . Where ( x => x . name . ToLower ( ) . Equals ( orgName . ToLower ( ) ) ) . FirstOrDefault ( ) ;
673675 }
674676
675677 private async Task < int > GetProfileTerm ( int profileId )
676678 {
677- var client = SectigoClient . InitializeClient ( _config ) ;
679+ var client = SectigoClient . InitializeClient ( _config , _certificateResolver ) ;
678680 var profileList = await client . ListSslProfiles ( ) ;
679681 return profileList . SslProfiles . Where ( x => x . id == profileId ) . FirstOrDefault ( ) . terms [ 0 ] ;
680682 }
681683
682684 private async Task < Profile > GetProfile ( int profileId )
683685 {
684- var client = SectigoClient . InitializeClient ( _config ) ;
686+ var client = SectigoClient . InitializeClient ( _config , _certificateResolver ) ;
685687 var profileList = await client . ListSslProfiles ( ) ;
686688 return profileList . SslProfiles . Where ( x => x . id == profileId ) . FirstOrDefault ( ) ;
687689 }
688690
689691 private async Task < List < int > > GetProfileIds ( )
690692 {
691- var client = SectigoClient . InitializeClient ( _config ) ;
693+ var client = SectigoClient . InitializeClient ( _config , _certificateResolver ) ;
692694 var profileList = await client . ListSslProfiles ( ) ;
693695 return profileList . SslProfiles . Select ( x => x . id ) . ToList ( ) ;
694696 }
@@ -730,7 +732,7 @@ private async Task<EnrollmentResult> PickUpEnrolledCertificate(int sslId, string
730732 while ( retryCounter < _config . PickupRetries )
731733 {
732734 _logger . LogDebug ( $ "Try number { retryCounter + 1 } to pickup enrolled certificate") ;
733- var client = SectigoClient . InitializeClient ( _config ) ;
735+ var client = SectigoClient . InitializeClient ( _config , _certificateResolver ) ;
734736 var certificate = Task . Run ( async ( ) => await client . PickupCertificate ( sslId , subject ) ) . Result ;
735737 if ( certificate != null && ! String . IsNullOrEmpty ( certificate . Subject ) )
736738 {
@@ -765,7 +767,7 @@ public X509Certificate2 PickupSingleCert(int sslId, string subject)
765767 while ( retryCounter < _config . PickupRetries )
766768 {
767769 _logger . LogDebug ( $ "Try number { retryCounter + 1 } to pickup single certificate") ;
768- var client = SectigoClient . InitializeClient ( _config ) ;
770+ var client = SectigoClient . InitializeClient ( _config , _certificateResolver ) ;
769771 var certificate = Task . Run ( async ( ) => await client . PickupCertificate ( sslId , subject ) ) . Result ;
770772 if ( certificate != null && ! String . IsNullOrEmpty ( certificate . Subject ) )
771773 {
0 commit comments