Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,7 @@ Hotfixes for BaseOption flag for Renewal workflow
Hotfix for domain lookup

1.1.2
Hotfix for renewal workflow
Hotfix for renewal workflow

1.2.0
Add SyncProducts config to filter certificate sync by product ID
7 changes: 6 additions & 1 deletion readme_source.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,14 +152,19 @@ This is the password that will be used to connect to the GlobalSign API
OPTIONAL: If provided, full syncs will start at the specified date.
* ```SyncIntervalDays```
OPTIONAL: Required if SyncStartDate is used. Specifies how to page the certificate sync. Should be a value such that no interval of that length contains > 500 certificate enrollments.
* ```SyncProducts```
OPTIONAL: If provided as a comma-separated list of product IDs, will limit the certificate sync to only certificates of those products. If blank or not provided, will sync all certs.

```json
"CAConnection": {
"IsTest":"false",
"PickupRetries":5,
"PickupDelay":150,
"Username":"PAR12344_apiuser",
"Password":"password"
"Password":"password",
"SyncStartDate":"2020-01-01",
"SyncIntervalDays":30,
"SyncProducts":"PV_SHA2, PEV_SHA2"
},
```
## GatewayRegistration
Expand Down
1 change: 1 addition & 0 deletions src/GlobalSignCAProxy/GlobalSignCAConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public class GlobalSignCAConfig

public string SyncStartDate { get; set; }
public int SyncIntervalDays { get; set; }
public string SyncProducts { get; set; }

public string GetUrl(GlobalSignServiceType queryType)
{
Expand Down
26 changes: 25 additions & 1 deletion src/GlobalSignCAProxy/GlobalSignCAProxy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

using Newtonsoft.Json;

using Org.BouncyCastle.Asn1.IsisMtt.X509;
using Org.BouncyCastle.Crypto.Tls;

using System;
Expand Down Expand Up @@ -272,8 +273,31 @@ public override void Synchronize(ICertificateDataReader certificateDataReader, B
DateTime? syncFrom = certificateAuthoritySyncInfo.DoFullSync ? fullSyncFrom : certificateAuthoritySyncInfo.OverallLastSync;
var certs = apiClient.GetCertificatesForSync(certificateAuthoritySyncInfo.DoFullSync, syncFrom, fullSyncFrom, Config.SyncIntervalDays);

foreach (var c in certs)
bool productFilter = false;
List<string> products = null;
if (!string.IsNullOrEmpty(Config.SyncProducts))
{
products = Config.SyncProducts.Split(',').ToList();
products.ForEach(p => p.ToUpper());
productFilter = true;
}

foreach (var c in certs)
{
if (productFilter)
{
bool prodMatch = false;
if (c.OrderInfo?.ProductCode != null && products.Contains(c.OrderInfo.ProductCode.ToUpper()))
{
prodMatch = true;
}
if (!prodMatch)
{
Logger.Info($"Found certificate with product code {c.OrderInfo?.ProductCode}, which does not match the filter criteria. Skipping.");
continue;
}
}

GlobalSignOrderStatus orderStatus = (GlobalSignOrderStatus)Enum.Parse(typeof(GlobalSignOrderStatus), c.CertificateInfo.CertificateStatus);
DateTime? subDate = DateTime.TryParse(c.OrderInfo?.OrderDate, out DateTime orderDate) ? orderDate : (DateTime?)null;
DateTime? resDate = DateTime.TryParse(c.OrderInfo?.OrderCompleteDate, out DateTime completeDate) ? completeDate : (DateTime?)null;
Expand Down
Loading