Skip to content

Commit

Permalink
add syncfilter config options to annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
dgaley committed Aug 28, 2024
1 parent eb4978e commit 30a8f8e
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 4 deletions.
25 changes: 23 additions & 2 deletions digicert-certcentral-caplugin/CertCentralCAPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,27 @@ public Dictionary<string, PropertyConfigInfo> 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.",
Expand Down Expand Up @@ -618,9 +639,9 @@ public async Task Synchronize(BlockingCollection<AnyCAPluginCertificate> blockin
List<string> skippedOrders = new List<string>();
int certCount = 0;

string syncCAstring = string.Join(",", _config.SyncCAFilter ?? new List<string>());
string syncCAstring = _config.SyncCAFilter ?? string.Empty;
_logger.LogTrace($"Sync CAs: {syncCAstring}");
List<string> caList = _config.SyncCAFilter ?? new List<string>();
List<string> caList = _config.SyncCAs;
caList.ForEach(c => c.ToUpper());


Expand Down
17 changes: 15 additions & 2 deletions digicert-certcentral-caplugin/CertCentralConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,27 @@ public class CertCentralConfig

public CertCentralConfig()
{
SyncCAFilter = new List<string>();
}
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<string> SyncCAFilter { get; set; }
public string SyncCAFilter { get; set; }
public List<string> SyncCAs
{
get
{
if (!string.IsNullOrEmpty(SyncCAFilter))
{
return SyncCAFilter.Split(',').ToList();
}
else
{
return new List<string>();
}
}
}
public bool? FilterExpiredOrders { get; set; }
public int? SyncExpirationDays { get; set; }
}
Expand Down
3 changes: 3 additions & 0 deletions digicert-certcentral-caplugin/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 30a8f8e

Please sign in to comment.