-
Notifications
You must be signed in to change notification settings - Fork 0
Merge to main #44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merge to main #44
Changes from all commits
52eee75
70fe240
f9e1564
516d230
844a7e1
b0819c4
db730d5
aceca2d
a4dfbe2
d0e5a80
cd8fd90
19fae71
fe7e05d
8850680
d195faf
1b14604
a64934c
03a5fa5
208fece
509ad46
c3a719f
880f85a
1d8ade4
c01f0ce
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| using Keyfactor.Extensions.CAPlugin.DigiCert.Models; | ||
| using Newtonsoft.Json; | ||
|
|
||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.Linq; | ||
| using System.Text; | ||
| using System.Threading.Tasks; | ||
|
|
||
| namespace Keyfactor.Extensions.CAPlugin.DigiCert.API | ||
| { | ||
| [Serializable] | ||
| public class DuplicateRequest : CertCentralBaseRequest | ||
| { | ||
| public DuplicateRequest(uint orderId) | ||
| { | ||
| Method = "POST"; | ||
| OrderId = orderId; | ||
| Resource = $"services/v2/order/certificate/{OrderId}/duplicate"; | ||
| Certificate = new CertificateDuplicateRequest(); | ||
| } | ||
|
|
||
| [JsonProperty("certificate")] | ||
| public CertificateDuplicateRequest Certificate { get; set; } | ||
|
|
||
| [JsonProperty("order_id")] | ||
| public uint OrderId { get; set; } | ||
|
|
||
| [JsonProperty("skip_approval")] | ||
| public bool SkipApproval { get; set; } | ||
| } | ||
|
|
||
| public class CertificateDuplicateRequest | ||
| { | ||
| [JsonProperty("common_name")] | ||
| public string CommonName { get; set; } | ||
|
|
||
| [JsonProperty("dns_names")] | ||
| public List<string> DnsNames { get; set; } | ||
|
|
||
| [JsonProperty("csr")] | ||
| public string CSR { get; set; } | ||
|
|
||
| [JsonProperty("server_platform")] | ||
| public Server_platform ServerPlatform { get; set; } | ||
|
|
||
| [JsonProperty("signature_hash")] | ||
| public string SignatureHash { get; set; } | ||
|
|
||
| [JsonProperty("ca_cert_id")] | ||
| public string CACertID { get; set; } | ||
| } | ||
|
|
||
| public class DuplicateResponse : CertCentralBaseResponse | ||
| { | ||
| public DuplicateResponse() | ||
| { | ||
| Requests = new List<Requests>(); | ||
| } | ||
|
|
||
| [JsonProperty("id")] | ||
| public int OrderId { get; set; } | ||
|
|
||
| [JsonProperty("requests")] | ||
| public List<Requests> Requests { get; set; } | ||
|
|
||
| [JsonProperty("certificate_chain")] | ||
| public List<CertificateChainElement> CertificateChain { get; set; } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -16,6 +16,7 @@ | |||||||||||||||||||||||||||||||
| using Newtonsoft.Json; | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| using Org.BouncyCastle.Asn1.X509; | ||||||||||||||||||||||||||||||||
| using Org.BouncyCastle.Pqc.Crypto.Falcon; | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| using System.Collections.Concurrent; | ||||||||||||||||||||||||||||||||
| using System.Runtime.InteropServices; | ||||||||||||||||||||||||||||||||
|
|
@@ -294,33 +295,62 @@ public async Task<EnrollmentResult> Enroll(string csr, string subject, Dictionar | |||||||||||||||||||||||||||||||
| string priorCertSnString = null; | ||||||||||||||||||||||||||||||||
| string priorCertReqID = null; | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| // Current gateway core leaves it up to the integration to determine if it is a renewal or a reissue | ||||||||||||||||||||||||||||||||
| if (typeOfCert.Equals("ssl") && Convert.ToBoolean(productInfo.ProductParameters[CertCentralConstants.Config.INCLUDE_CLIENT_AUTH])) | ||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||
|
Comment on lines
+298
to
+299
|
||||||||||||||||||||||||||||||||
| if (typeOfCert.Equals("ssl") && Convert.ToBoolean(productInfo.ProductParameters[CertCentralConstants.Config.INCLUDE_CLIENT_AUTH])) | |
| { | |
| bool includeClientAuth = false; | |
| if (productInfo.ProductParameters.ContainsKey(CertCentralConstants.Config.INCLUDE_CLIENT_AUTH)) | |
| { | |
| var includeClientAuthRaw = productInfo.ProductParameters[CertCentralConstants.Config.INCLUDE_CLIENT_AUTH]; | |
| if (!bool.TryParse(Convert.ToString(includeClientAuthRaw), out includeClientAuth)) | |
| { | |
| _logger.LogWarning($"Could not parse '{CertCentralConstants.Config.INCLUDE_CLIENT_AUTH}' field as true or false. Treating as false. Value: {includeClientAuthRaw}"); | |
| includeClientAuth = false; | |
| } | |
| } | |
| if (typeOfCert.Equals("ssl") && includeClientAuth) | |
| { |
Copilot
AI
Feb 12, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct spelling in comment: “accomodate” → “accommodate”.
| // DigiCert issue with treating the timezone as mountain time. -7 hours to accomodate DST | |
| // DigiCert issue with treating the timezone as mountain time. -7 hours to accommodate DST |
Copilot
AI
Feb 12, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pemList.Contains(...) inside the loop makes duplicate detection O(n²) as the number of certs grows. Use a HashSet<string> for pemList to get O(1) lookups and simplify the “contains then add” logic.
Copilot
AI
Feb 12, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct spelling in comment: “arround” → “around”.
| //Another check for duplicate PEMs to get arround issue with DigiCert API returning incorrect data sometimes on reissued/duplicate certs | |
| //Another check for duplicate PEMs to get around issue with DigiCert API returning incorrect data sometimes on reissued/duplicate certs |
Copilot
AI
Feb 12, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pemList.Contains(...) inside the loop makes duplicate detection O(n²) as the number of certs grows. Use a HashSet<string> for pemList to get O(1) lookups and simplify the “contains then add” logic.
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -97,7 +97,7 @@ | |||||
|
|
||||||
| Logger.LogTrace($"Entered CertCentral Request (ID: {reqID}) Method: {request.Method} - URL: {targetURI}"); | ||||||
|
|
||||||
| HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(targetURI); | ||||||
|
Check warning on line 100 in digicert-certcentral-caplugin/Client/CertCentralClient.cs
|
||||||
| objRequest.Method = request.Method; | ||||||
| objRequest.Headers.Add("X-DC-DEVKEY", this.CertCentralCreds.APIKey); | ||||||
|
|
||||||
|
|
@@ -148,13 +148,13 @@ | |||||
| } | ||||||
| else | ||||||
| { | ||||||
| Logger.LogDebug("CertCentral Response Error", wex); | ||||||
|
Check warning on line 151 in digicert-certcentral-caplugin/Client/CertCentralClient.cs
|
||||||
| throw new Exception("Unable to establish connection to CertCentral web service", wex); | ||||||
| } | ||||||
| } | ||||||
| catch (Exception ex) | ||||||
| { | ||||||
| Logger.LogError("CertCentral Response Error", ex); | ||||||
|
Check warning on line 157 in digicert-certcentral-caplugin/Client/CertCentralClient.cs
|
||||||
| throw new Exception("Unable to establish connection to CertCentral web service", ex); | ||||||
| } | ||||||
|
|
||||||
|
|
@@ -357,6 +357,28 @@ | |||||
| return reissueResponse; | ||||||
| } | ||||||
|
|
||||||
| public OrderResponse DuplicateCertificate(DuplicateRequest request) | ||||||
| { | ||||||
| string jsonRequest = JsonConvert.SerializeObject(request, Formatting.None, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }); | ||||||
| Logger.LogTrace($"Duplicate request:\n{jsonRequest}"); | ||||||
|
||||||
| Logger.LogTrace($"Duplicate request:\n{jsonRequest}"); | |
| Logger.LogTrace("Duplicate certificate request initiated."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This new file includes unused
usingdirectives (System.Linq,System.Text,System.Threading.Tasksaren’t used in the shown code). Removing them reduces clutter and avoids warnings (especially if warnings are treated as errors in CI).