Skip to content

Commit

Permalink
Merge pull request #16 for release 2.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
doebrowsk authored Jan 23, 2025
2 parents eff9de9 + c4bc256 commit 7dd3e56
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
### 2.0.0
* Initial Public Release

### 2.0.1
* Add configuration fields to support sync filtering
* Bug fixes around SAN processing
37 changes: 35 additions & 2 deletions digicert-certcentral-caplugin/CertCentralCAPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ public void Initialize(IAnyCAPluginConfigProvider configProvider, ICertificateDa
public async Task<EnrollmentResult> Enroll(string csr, string subject, Dictionary<string, string[]> san, EnrollmentProductInfo productInfo, RequestFormat requestFormat, EnrollmentType enrollmentType)
{
_logger.MethodEntry(LogLevel.Trace);
_logger.LogDebug($"Enrolling for certificate with subject {subject}");
foreach (var sanlist in san)
{
string sans = string.Join(",", sanlist.Value);
_logger.LogDebug($"SANs type \"{sanlist.Key}\": {sans}");
}
OrderResponse orderResponse = new OrderResponse();
CertCentralCertType certType = CertCentralCertType.GetAllTypes(_config).FirstOrDefault(x => x.ProductCode.Equals(productInfo.ProductID));
OrderRequest orderRequest = new OrderRequest(certType);
Expand Down Expand Up @@ -87,6 +93,10 @@ public async Task<EnrollmentResult> Enroll(string csr, string subject, Dictionar
{
dnsNames = new List<string>(san["Dns"]);
}
if (san.ContainsKey("dnsname"))
{
dnsNames = new List<string>(san["dnsname"]);
}

X509Name subjectParsed = null;
string commonName = null, organization = null, orgUnit = null;
Expand Down Expand Up @@ -356,6 +366,28 @@ 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 +650,10 @@ 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
20 changes: 18 additions & 2 deletions digicert-certcentral-caplugin/CertCentralConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,30 @@ 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 7dd3e56

Please sign in to comment.