From 90a7cd665973336510514eb112de85461cf8e9c6 Mon Sep 17 00:00:00 2001 From: Pichatorn-A4K Date: Fri, 11 Sep 2026 02:18:28 +0700 Subject: [PATCH] Do not fetch the same order twice per synchronized order GetAllConnectorCertsForOrder() calls ViewCertificateOrder() and then calls GetAllCertsForOrder(orderId), which issues the identical GET /services/v2/order/certificate/{id} again. Every order in a sync therefore costs two of those calls instead of one. That matters against DigiCert's documented burst limit of 100 requests per 5 seconds: a sync already spends roughly four GETs per order plus one per certificate, so the duplicate is about a fifth of the budget spent on a response the caller is already holding. The parameter is optional, so no other call site changes. --- digicert-certcentral-caplugin/CertCentralCAPlugin.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/digicert-certcentral-caplugin/CertCentralCAPlugin.cs b/digicert-certcentral-caplugin/CertCentralCAPlugin.cs index 176c2bd..7177492 100644 --- a/digicert-certcentral-caplugin/CertCentralCAPlugin.cs +++ b/digicert-certcentral-caplugin/CertCentralCAPlugin.cs @@ -585,7 +585,7 @@ public async Task GetSingleRecord(string caRequestID) CertCentralClient client = CertCentralClientUtilities.BuildCertCentralClient(_config); ViewCertificateOrderResponse orderResponse = client.ViewCertificateOrder(new ViewCertificateOrderRequest((uint)orderId)); - var orderCerts = GetAllCertsForOrder(orderId); + var orderCerts = GetAllCertsForOrder(orderId, orderResponse); StatusOrder certToCheck = orderCerts.Where(c => c.certificate_id == certIdInt).First(); @@ -1757,10 +1757,13 @@ private List GetAllConnectorCertsForOrder(string caReque /// /// /// - private List GetAllCertsForOrder(int orderId) + private List GetAllCertsForOrder(int orderId, ViewCertificateOrderResponse alreadyFetchedOrder = null) { CertCentralClient client = CertCentralClientUtilities.BuildCertCentralClient(_config); - ViewCertificateOrderResponse orderResponse = client.ViewCertificateOrder(new ViewCertificateOrderRequest((uint)orderId)); + // Reuse the caller's response when it has one: GetAllConnectorCertsForOrder has just + // fetched this same order. + ViewCertificateOrderResponse orderResponse = alreadyFetchedOrder + ?? client.ViewCertificateOrder(new ViewCertificateOrderRequest((uint)orderId)); if (orderResponse.Status == CertCentralBaseResponse.StatusType.ERROR) { string errorMessage = String.Format("Request {0} was not found in CertCentral database or is not valid", orderId);