Skip to content
Merged
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 @@ -2,4 +2,7 @@ v1.0
-Initial Release.

1.1
Remove retry logic around reissue pickups
Remove retry logic around reissue pickups

1.1.1
Change incremental sync to use GetModifiedOrders API call
56 changes: 53 additions & 3 deletions globalsign-mssl-caplugin/Client/GlobalSignApiClient.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using System.Globalization;
using System.ServiceModel;
using System.Text;

using Keyfactor.AnyGateway.Extensions;
using Keyfactor.Extensions.CAPlugin.GlobalSign.Api;
using Keyfactor.Logging;
Expand All @@ -21,7 +23,7 @@
public ManagedSSLV2 OrderService;
public GASV1 QueryService;

public GlobalSignApiClient(GlobalSignCAConfig config, ILogger logger)

Check warning on line 26 in globalsign-mssl-caplugin/Client/GlobalSignApiClient.cs

View workflow job for this annotation

GitHub Actions / call-starter-workflow / call-generate-readme-workflow / Use private doctool action in public repository

Non-nullable field 'OrderService' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check warning on line 26 in globalsign-mssl-caplugin/Client/GlobalSignApiClient.cs

View workflow job for this annotation

GitHub Actions / call-starter-workflow / call-generate-readme-workflow / Use private doctool action in public repository

Non-nullable field 'QueryService' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check warning on line 26 in globalsign-mssl-caplugin/Client/GlobalSignApiClient.cs

View workflow job for this annotation

GitHub Actions / call-starter-workflow / call-generate-readme-workflow / Use private doctool action in public repository

Non-nullable field 'OrderService' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check warning on line 26 in globalsign-mssl-caplugin/Client/GlobalSignApiClient.cs

View workflow job for this annotation

GitHub Actions / call-starter-workflow / call-dotnet-build-and-release-workflow / dotnet-build-and-release

Non-nullable field 'QueryService' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check warning on line 26 in globalsign-mssl-caplugin/Client/GlobalSignApiClient.cs

View workflow job for this annotation

GitHub Actions / call-starter-workflow / call-dotnet-build-and-release-workflow / dotnet-build-and-release

Non-nullable field 'OrderService' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check warning on line 26 in globalsign-mssl-caplugin/Client/GlobalSignApiClient.cs

View workflow job for this annotation

GitHub Actions / call-starter-workflow / call-dotnet-build-and-release-workflow / dotnet-build-and-release

Non-nullable field 'QueryService' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check warning on line 26 in globalsign-mssl-caplugin/Client/GlobalSignApiClient.cs

View workflow job for this annotation

GitHub Actions / call-starter-workflow / call-dotnet-build-and-release-workflow / dotnet-build-and-release

Non-nullable field 'OrderService' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check warning on line 26 in globalsign-mssl-caplugin/Client/GlobalSignApiClient.cs

View workflow job for this annotation

GitHub Actions / call-starter-workflow / call-dotnet-build-and-release-workflow / dotnet-build-and-release

Non-nullable field 'QueryService' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check warning on line 26 in globalsign-mssl-caplugin/Client/GlobalSignApiClient.cs

View workflow job for this annotation

GitHub Actions / call-starter-workflow / call-dotnet-build-and-release-workflow / dotnet-build-and-release

Non-nullable field 'OrderService' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check warning on line 26 in globalsign-mssl-caplugin/Client/GlobalSignApiClient.cs

View workflow job for this annotation

GitHub Actions / call-starter-workflow / call-dotnet-build-and-release-workflow / dotnet-build-and-release

Non-nullable field 'OrderService' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check warning on line 26 in globalsign-mssl-caplugin/Client/GlobalSignApiClient.cs

View workflow job for this annotation

GitHub Actions / call-starter-workflow / call-dotnet-build-and-release-workflow / dotnet-build-and-release

Non-nullable field 'QueryService' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check warning on line 26 in globalsign-mssl-caplugin/Client/GlobalSignApiClient.cs

View workflow job for this annotation

GitHub Actions / call-starter-workflow / call-dotnet-build-and-release-workflow / dotnet-build-and-release

Non-nullable field 'OrderService' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.
{
Logger = logger;
Config = config;
Expand Down Expand Up @@ -86,7 +88,7 @@
var to = DateTime.UtcNow;

results.AddRange(
await GetCertificatesByDateRange(from, to)
await GetModifiedOrdersByDateRange(from, to)
);
}

Expand Down Expand Up @@ -126,17 +128,65 @@
else
{
int errCode = int.Parse(allOrdersResponse.Response.QueryResponseHeader.Errors[0].ErrorCode);
Logger.LogError($"Unable to retrieve certificates:");
StringBuilder sb = new StringBuilder();
sb.Append($"Unable to retrieve certificates:");
foreach (var e in allOrdersResponse.Response.QueryResponseHeader.Errors)
{
Logger.LogError($"{e.ErrorCode} | {e.ErrorField} | {e.ErrorMessage}");
sb.Append($"\n{e.ErrorCode} | {e.ErrorField} | {e.ErrorMessage}");
}
Logger.LogError(sb.ToString());
var gsError = GlobalSignErrorIndex.GetGlobalSignError(errCode);
Logger.LogError(gsError.DetailedMessage);
throw new Exception(gsError.Message);
}
}

private async Task<List<OrderDetail>> GetModifiedOrdersByDateRange(DateTime? fromDate, DateTime? toDate)
{
var tmpFromDate = fromDate ?? DateTime.MinValue;
var tmpToDate = toDate ?? DateTime.UtcNow;

QbV1GetModifiedOrdersRequest req = new QbV1GetModifiedOrdersRequest
{
QueryRequestHeader = new QueryRequestHeader
{
AuthToken = Config.GetQueryAuthToken()
},
FromDate = tmpFromDate.ToString(Config.DateFormatString, DateTimeFormatInfo.InvariantInfo),
ToDate = tmpToDate.ToString(Config.DateFormatString, DateTimeFormatInfo.InvariantInfo),
OrderQueryOption = new OrderQueryOption
{
ReturnOrderOption = "true",
ReturnCertificateInfo = "true",
ReturnFulfillment = "true",
ReturnOriginalCSR = "true"
}
};
Logger.LogDebug($"Retrieving all modified orders between {tmpFromDate} and {tmpToDate}");
var modOrdersResponse = await QueryService.GetModifiedOrdersAsync(new GetModifiedOrders(req));

if (modOrdersResponse.Response.QueryResponseHeader.SuccessCode == 0)
{
var retVal = modOrdersResponse.Response.OrderDetails?.ToList() ?? new List<OrderDetail>();
Logger.LogDebug($"Retrieved {retVal.Count} modified orders from GlobalSign");
return retVal;
}
else
{
int errCode = int.Parse(modOrdersResponse.Response.QueryResponseHeader.Errors[0].ErrorCode);
StringBuilder sb = new StringBuilder();
sb.Append("Unable to retrieve certificates:");
foreach (var e in modOrdersResponse.Response.QueryResponseHeader.Errors)
{
sb.Append($"\n{e.ErrorCode} | {e.ErrorField} | {e.ErrorMessage}");
}
Logger.LogError(sb.ToString());
var gsError = GlobalSignErrorIndex.GetGlobalSignError(errCode);
Logger.LogError(gsError.DetailedMessage);
throw new Exception(gsError.Message);
}
}

public async Task<AnyCAPluginCertificate> PickupCertificateById(string caRequestId)
{
Logger.MethodEntry();
Expand Down
Loading