Skip to content

Commit

Permalink
Fixed Certificate Sync Issues
Browse files Browse the repository at this point in the history
  • Loading branch information
bhillkeyfactor committed Nov 8, 2021
1 parent c0a03b9 commit c55c3b1
Showing 1 changed file with 19 additions and 13 deletions.
32 changes: 19 additions & 13 deletions DigiCertSymCaProxy/Client/DigiCertSymClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -185,32 +185,37 @@ public async Task SubmitQueryOrderRequestAsync(BlockingCollection<ICertificateDe
try
{
var itemsProcessed = 0;
var pageCounter = 0;
var pageCounter = 1;
var isComplete = false;
var retryCount = 0;

foreach (var seat in SeatList.Split(','))
{
pageCounter = 1;
do
{
pageCounter++;
var queryOrderRequest =
requestManager.GetSearchCertificatesRequest(pageCounter, seat);
var batchItemsProcessed = 0;
using (var resp = await RestClient.PostAsync("/mpki/api/v1/searchcert", new StringContent(
JsonConvert.SerializeObject(queryOrderRequest), Encoding.ASCII, "application/json"), ct))
{
if (!resp.IsSuccessStatusCode)
{
var responseMessage = resp.Content.ReadAsStringAsync().Result;
Logger.Error(
$"Failed Request to SslStore. Retrying request. Status Code {resp.StatusCode} | Message: {responseMessage}");
retryCount++;
if (retryCount > 5)
throw new RetryCountExceededException(
$"5 consecutive failures to {resp.RequestMessage.RequestUri}");

continue;
if (!resp.IsSuccessStatusCode)
{
var responseMessage = resp.Content.ReadAsStringAsync().Result;
//igngore missing Certificate in search 404 errors
if (!responseMessage.Contains("entity_not_found"))
{
Logger.Error(
$"Failed Request to Digicert mPKI. Retrying request. Status Code {resp.StatusCode} | Message: {responseMessage}");
retryCount++;
if (retryCount > 5)
throw new RetryCountExceededException(
$"5 consecutive failures to {resp.RequestMessage.RequestUri}");
}
break; //Seat has no certs move on to the next seat
}

var response = JsonConvert.DeserializeObject<CertificateSearchResponse>(
await resp.Content.ReadAsStringAsync());
Expand Down Expand Up @@ -239,7 +244,8 @@ public async Task SubmitQueryOrderRequestAsync(BlockingCollection<ICertificateDe

//assume that if we process less records than requested that we have reached the end of the certificate list
if (batchItemsProcessed < PageSize)
isComplete = true;
isComplete = true;
pageCounter = pageCounter + PageSize;
} while (!isComplete); //page loop
}
bc.CompleteAdding();
Expand Down

0 comments on commit c55c3b1

Please sign in to comment.