Skip to content

Commit b7e2213

Browse files
committed
feat: hardcode GetProductIds and auto-map product names to numeric codes
GetProductIds now returns a static list so the CI doc tool (which uses reflection, not a live API call) can populate integration-manifest.json correctly without resetting product_ids to []. A DefaultProductCodes map in Constants.Products resolves the selected product name (e.g. "DV SSL") to its production numeric code ("838") automatically, so operators no longer need to look up and enter codes manually. ProductCode template param remains available as an explicit override for sandbox environments or non-standard codes.
1 parent e8d9066 commit b7e2213

4 files changed

Lines changed: 48 additions & 11 deletions

File tree

CERTInext/CERTInextCAPluginConfig.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,9 +172,9 @@ public static Dictionary<string, PropertyConfigInfo> GetTemplateParameterAnnotat
172172
{
173173
[Constants.EnrollmentParam.ProductCode] = new PropertyConfigInfo
174174
{
175-
Comments = "REQUIRED: The numeric CERTInext product code for this certificate type " +
176-
"(e.g. '844' for DV SSL 1-year). Provided by eMudhra for your account. " +
177-
"Overrides the connector-level DefaultProductCode when set.",
175+
Comments = "OPTIONAL: Override the numeric CERTInext product code for this template. " +
176+
"When omitted, the default production code for the selected product is used automatically " +
177+
"(e.g. DV SSL → 838). Set this explicitly when targeting sandbox or a non-standard code.",
178178
Hidden = false,
179179
DefaultValue = string.Empty,
180180
Type = "String"

CERTInext/Constants.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,32 @@ public static class EnrollmentParam
6363
public const string KeyType = "KeyType";
6464
}
6565

66+
public static class Products
67+
{
68+
public const string DvSsl = "DV SSL";
69+
public const string DvSslWildcard = "DV SSL Wildcard";
70+
public const string DvSslUcc = "DV SSL Multi-Domain (UCC)";
71+
public const string OvSsl = "OV SSL";
72+
public const string OvSslWildcard = "OV SSL Wildcard";
73+
public const string OvSslUcc = "OV SSL Multi-Domain (UCC)";
74+
public const string EvSsl = "EV SSL";
75+
76+
// Default production numeric codes. These are the standard codes for the
77+
// CERTInext production environment. Sandbox codes differ — set ProductCode
78+
// explicitly on the template to override when targeting sandbox.
79+
public static readonly System.Collections.Generic.Dictionary<string, string> DefaultProductCodes =
80+
new System.Collections.Generic.Dictionary<string, string>(System.StringComparer.OrdinalIgnoreCase)
81+
{
82+
[DvSsl] = "838",
83+
[DvSslWildcard] = "839",
84+
[DvSslUcc] = "840",
85+
[OvSsl] = "842",
86+
[OvSslWildcard] = "843",
87+
[OvSslUcc] = "844",
88+
[EvSsl] = "846",
89+
};
90+
}
91+
6692
public static class CertificateStatusId
6793
{
6894
// CERTInext certificateStatusId integer values (from TrackOrder response)

CERTInext/Models/EnrollmentParams.cs

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,25 @@ public EnrollmentParams(EnrollmentProductInfo productInfo)
2929
public string ProductId { get; }
3030

3131
/// <summary>
32-
/// The CERTInext numeric product code configured on the template.
33-
/// Falls back to the deprecated ProfileId parameter for backward compat.
34-
/// Must be a numeric string (e.g. "838") — the gateway ProductID is a human-readable
35-
/// name and cannot be passed to the API.
32+
/// The CERTInext numeric product code to send to the API.
33+
/// Resolution order:
34+
/// 1. ProductCode template parameter (explicit override — use for sandbox or non-standard codes)
35+
/// 2. ProfileId template parameter (deprecated alias for ProductCode)
36+
/// 3. Default production code looked up from the selected product name (ProductId)
3637
/// </summary>
37-
public string ProductCode =>
38-
GetString(Constants.EnrollmentParam.ProductCode,
39-
GetString(Constants.EnrollmentParam.ProfileId, string.Empty));
38+
public string ProductCode
39+
{
40+
get
41+
{
42+
var explicit_ = GetString(Constants.EnrollmentParam.ProductCode,
43+
GetString(Constants.EnrollmentParam.ProfileId, string.Empty));
44+
if (!string.IsNullOrEmpty(explicit_))
45+
return explicit_;
46+
47+
Constants.Products.DefaultProductCodes.TryGetValue(ProductId ?? string.Empty, out var mapped);
48+
return mapped ?? string.Empty;
49+
}
50+
}
4051

4152
/// <summary>Alias for ProductCode — kept for backward compat.</summary>
4253
public string ProfileId => ProductCode;

docsource/configuration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ In the Keyfactor Command Management Portal, navigate to **Certificate Templates*
125125

126126
| Parameter | Required / Optional | Type | Description | Example / Default |
127127
|---|---|---|---|---|
128-
| `ProductCode` | Required | String | The numeric CERTInext product code for the type of certificate to issue (e.g. `838` for DV SSL). Overrides the connector-level `DefaultProductCode` when set. See the product code table below. | `838` |
128+
| `ProductCode` | Optional | String | Override the numeric CERTInext product code for this template. When omitted, the default production code for the selected product is used automatically (e.g. selecting **DV SSL** defaults to `838`). Set this explicitly when targeting the sandbox environment or a non-standard product code. | `838` |
129129
| `ProfileId` | Deprecated | String | Legacy alias for `ProductCode`. Accepted for backward compatibility — if `ProductCode` is not set, `ProfileId` is used in its place. New templates should use `ProductCode`. | `838` |
130130
| `ValidityYears` | Optional | Number | Subscription validity period in years: `1`, `2`, or `3`. Default: `1`. CERTInext certificates are issued within a subscription term at up to 390 days per certificate, with free renewals within the term. | `1` |
131131
| `ValidityDays` | Deprecated | Number | Legacy validity field. If set, the value is divided by 365 and rounded up to derive a year count. New templates should use `ValidityYears`. | `365` |

0 commit comments

Comments
 (0)