Skip to content

Commit 7dd3e56

Browse files
authored
Merge pull request #16 for release 2.0.1
2 parents eff9de9 + c4bc256 commit 7dd3e56

4 files changed

Lines changed: 60 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
11
### 2.0.0
22
* Initial Public Release
3+
4+
### 2.0.1
5+
* Add configuration fields to support sync filtering
6+
* Bug fixes around SAN processing

digicert-certcentral-caplugin/CertCentralCAPlugin.cs

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@ public void Initialize(IAnyCAPluginConfigProvider configProvider, ICertificateDa
5858
public async Task<EnrollmentResult> Enroll(string csr, string subject, Dictionary<string, string[]> san, EnrollmentProductInfo productInfo, RequestFormat requestFormat, EnrollmentType enrollmentType)
5959
{
6060
_logger.MethodEntry(LogLevel.Trace);
61+
_logger.LogDebug($"Enrolling for certificate with subject {subject}");
62+
foreach (var sanlist in san)
63+
{
64+
string sans = string.Join(",", sanlist.Value);
65+
_logger.LogDebug($"SANs type \"{sanlist.Key}\": {sans}");
66+
}
6167
OrderResponse orderResponse = new OrderResponse();
6268
CertCentralCertType certType = CertCentralCertType.GetAllTypes(_config).FirstOrDefault(x => x.ProductCode.Equals(productInfo.ProductID));
6369
OrderRequest orderRequest = new OrderRequest(certType);
@@ -87,6 +93,10 @@ public async Task<EnrollmentResult> Enroll(string csr, string subject, Dictionar
8793
{
8894
dnsNames = new List<string>(san["Dns"]);
8995
}
96+
if (san.ContainsKey("dnsname"))
97+
{
98+
dnsNames = new List<string>(san["dnsname"]);
99+
}
90100

91101
X509Name subjectParsed = null;
92102
string commonName = null, organization = null, orgUnit = null;
@@ -356,6 +366,28 @@ public Dictionary<string, PropertyConfigInfo> GetCAConnectorAnnotations()
356366
DefaultValue = false,
357367
Type = "Boolean"
358368
},
369+
370+
[CertCentralConstants.Config.SYNC_CA_FILTER] = new PropertyConfigInfo()
371+
{
372+
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.",
373+
Hidden = false,
374+
DefaultValue = "",
375+
Type = "String"
376+
},
377+
[CertCentralConstants.Config.FILTER_EXPIRED] = new PropertyConfigInfo()
378+
{
379+
Comments = "If set to 'true', syncing will apply a filter to not return orders that are expired for longer than specified in SyncExpirationDays.",
380+
Hidden = false,
381+
DefaultValue = false,
382+
Type = "Boolean"
383+
},
384+
[CertCentralConstants.Config.SYNC_EXPIRATION_DAYS] = new PropertyConfigInfo()
385+
{
386+
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.",
387+
Hidden = false,
388+
DefaultValue = 30,
389+
Type = "Number"
390+
},
359391
[CertCentralConstants.Config.ENABLED] = new PropertyConfigInfo()
360392
{
361393
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 +650,10 @@ public async Task Synchronize(BlockingCollection<AnyCAPluginCertificate> blockin
618650
List<string> skippedOrders = new List<string>();
619651
int certCount = 0;
620652

621-
string syncCAstring = string.Join(",", _config.SyncCAFilter ?? new List<string>());
653+
string syncCAstring = _config.SyncCAFilter ?? string.Empty;
622654
_logger.LogTrace($"Sync CAs: {syncCAstring}");
623-
List<string> caList = _config.SyncCAFilter ?? new List<string>();
655+
List<string> caList = _config.SyncCAs;
656+
624657
caList.ForEach(c => c.ToUpper());
625658

626659

digicert-certcentral-caplugin/CertCentralConfig.cs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,30 @@ public class CertCentralConfig
1111

1212
public CertCentralConfig()
1313
{
14-
SyncCAFilter = new List<string>();
14+
1515
}
1616
public string APIKey { get; set; }
1717
public string Region { get; set; } = "US";
1818
public int? DivisionId { get; set; }
1919
public bool? RevokeCertificateOnly { get; set; }
2020
public bool Enabled { get; set; } = true;
21-
public List<string> SyncCAFilter { get; set; }
21+
22+
public string SyncCAFilter { get; set; }
23+
public List<string> SyncCAs
24+
{
25+
get
26+
{
27+
if (!string.IsNullOrEmpty(SyncCAFilter))
28+
{
29+
return SyncCAFilter.Split(',').ToList();
30+
}
31+
else
32+
{
33+
return new List<string>();
34+
}
35+
}
36+
}
37+
2238
public bool? FilterExpiredOrders { get; set; }
2339
public int? SyncExpirationDays { get; set; }
2440
}

digicert-certcentral-caplugin/Constants.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ public class Config
2727
public const string RENEWAL_WINDOW = "RenewalWindowDays";
2828
public const string REVOKE_CERT = "RevokeCertificateOnly";
2929
public const string ENABLED = "Enabled";
30+
public const string SYNC_CA_FILTER = "SyncCAFilter";
31+
public const string FILTER_EXPIRED = "FilterExpiredOrders";
32+
public const string SYNC_EXPIRATION_DAYS = "SyncExpirationDays";
3033
}
3134

3235
public class RequestAttributes

0 commit comments

Comments
 (0)