diff --git a/digicert-certcentral-caplugin/CertCentralCAPlugin.cs b/digicert-certcentral-caplugin/CertCentralCAPlugin.cs index a617eca..ee90001 100644 --- a/digicert-certcentral-caplugin/CertCentralCAPlugin.cs +++ b/digicert-certcentral-caplugin/CertCentralCAPlugin.cs @@ -356,6 +356,27 @@ public Dictionary GetCAConnectorAnnotations() DefaultValue = false, Type = "Boolean" }, + [CertCentralConstants.Config.SYNC_CA_FILTER] = new PropertyConfigInfo() + { + Comments = "If you list one or more CA IDs here (comma-separated), the sync process will only sync records from those CAs. If you want to sync all CA IDs, leave this field empty.", + Hidden = false, + DefaultValue = "", + Type = "String" + }, + [CertCentralConstants.Config.FILTER_EXPIRED] = new PropertyConfigInfo() + { + Comments = "If set to 'true', syncing will apply a filter to not return orders that are expired for longer than specified in SyncExpirationDays.", + Hidden = false, + DefaultValue = false, + Type = "Boolean" + }, + [CertCentralConstants.Config.SYNC_EXPIRATION_DAYS] = new PropertyConfigInfo() + { + Comments = "If FilterExpiredOrders is set to true, this setting determines how many days in the past to still return expired orders. For example, a value of 30 means the sync will return any certs that expired within the past 30 days. A value of 0 means the sync will not return any certs that expired before the current day. This value is ignored if FilterExpiredOrders is false.", + Hidden = false, + DefaultValue = 30, + Type = "Number" + }, [CertCentralConstants.Config.ENABLED] = new PropertyConfigInfo() { Comments = "Flag to Enable or Disable gateway functionality. Disabling is primarily used to allow creation of the CA prior to configuration information being available.", @@ -618,9 +639,9 @@ public async Task Synchronize(BlockingCollection blockin List skippedOrders = new List(); int certCount = 0; - string syncCAstring = string.Join(",", _config.SyncCAFilter ?? new List()); + string syncCAstring = _config.SyncCAFilter ?? string.Empty; _logger.LogTrace($"Sync CAs: {syncCAstring}"); - List caList = _config.SyncCAFilter ?? new List(); + List caList = _config.SyncCAs; caList.ForEach(c => c.ToUpper()); diff --git a/digicert-certcentral-caplugin/CertCentralConfig.cs b/digicert-certcentral-caplugin/CertCentralConfig.cs index ed0320f..9c16db3 100644 --- a/digicert-certcentral-caplugin/CertCentralConfig.cs +++ b/digicert-certcentral-caplugin/CertCentralConfig.cs @@ -11,14 +11,27 @@ public class CertCentralConfig public CertCentralConfig() { - SyncCAFilter = new List(); } public string APIKey { get; set; } public string Region { get; set; } = "US"; public int? DivisionId { get; set; } public bool? RevokeCertificateOnly { get; set; } public bool Enabled { get; set; } = true; - public List SyncCAFilter { get; set; } + public string SyncCAFilter { get; set; } + public List SyncCAs + { + get + { + if (!string.IsNullOrEmpty(SyncCAFilter)) + { + return SyncCAFilter.Split(',').ToList(); + } + else + { + return new List(); + } + } + } public bool? FilterExpiredOrders { get; set; } public int? SyncExpirationDays { get; set; } } diff --git a/digicert-certcentral-caplugin/Constants.cs b/digicert-certcentral-caplugin/Constants.cs index 44aa10b..609ec3f 100644 --- a/digicert-certcentral-caplugin/Constants.cs +++ b/digicert-certcentral-caplugin/Constants.cs @@ -27,6 +27,9 @@ public class Config public const string RENEWAL_WINDOW = "RenewalWindowDays"; public const string REVOKE_CERT = "RevokeCertificateOnly"; public const string ENABLED = "Enabled"; + public const string SYNC_CA_FILTER = "SyncCAFilter"; + public const string FILTER_EXPIRED = "FilterExpiredOrders"; + public const string SYNC_EXPIRATION_DAYS = "SyncExpirationDays"; } public class RequestAttributes