Skip to content

Commit b760cc8

Browse files
committed
feat(scripts): stage 02 per-env product codes; document SignerPlace + code mapping
- Add PRODUCT_CODE_MAP_JSON to stage 02 so each Templates[] entry carries the correct per-environment CERTInext ProductCode. The plugin's built-in defaults are production codes (e.g. DV SSL=838); sandbox accounts use different codes (842-851) which the gateway validates at config-PUT time. - Fix a ${VAR:-{}} brace-default bug that appended a stray '}' to a set value (broke --argjson when PRODUCT_CODE_MAP_JSON was provided). - Document in scripts/register/README.md: product codes are per-environment (names are stable), SignerPlace is required by CERTInext (no fallback), and /config/configuration has no GET so PUT replaces the full object. Verified end-to-end: a Command PFX enrollment for AnyCA_DV SSL now reaches CERTInext and parks at EXTERNAL_VALIDATION (DCV off), instead of failing on a missing template mapping.
1 parent 603d6bd commit b760cc8

2 files changed

Lines changed: 44 additions & 2 deletions

File tree

scripts/register/02-gateway-ca-config.sh

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,17 @@ MANIFEST="${MANIFEST:-$REPO_ROOT/integration-manifest.json}"
3434
DRY_RUN="${DRY_RUN:-0}"
3535
GATEWAY_LOGICAL_NAME="${GATEWAY_LOGICAL_NAME:-$CONFIGURATION_TENANT}"
3636
GATEWAY_CERT_FILE="${GATEWAY_CERT_FILE:-$REPO_ROOT/certinext-sandbox-chain.pem}"
37-
TEMPLATE_PARAMS_JSON="${TEMPLATE_PARAMS_JSON:-{}}"
37+
# NOTE: do not use ${VAR:-{}} — the first } closes the expansion, appending a
38+
# stray } when VAR is set. Guard with an explicit empty check instead.
39+
[ -n "${TEMPLATE_PARAMS_JSON:-}" ] || TEMPLATE_PARAMS_JSON='{}'
40+
# Per-product CERTInext product code overrides, keyed by product_id, e.g.
41+
# {"DV SSL":"842","OV SSL":"846"}. CERTInext numeric product codes are
42+
# PER-ENVIRONMENT (the plugin's built-in defaults are PRODUCTION codes like
43+
# 838; sandbox accounts use different codes). When a product_id has an entry
44+
# here, Parameters.ProductCode is set so the gateway validates against a code
45+
# that exists in the target account. Discover codes via GetProductDetails
46+
# (scripts/get-product-details.sh). Products not listed fall back to defaults.
47+
[ -n "${PRODUCT_CODE_MAP_JSON:-}" ] || PRODUCT_CODE_MAP_JSON='{}'
3848
FULL_SCAN_MINUTES="${FULL_SCAN_MINUTES:-720}"
3949
INCR_SCAN_MINUTES="${INCR_SCAN_MINUTES:-5}"
4050

@@ -89,7 +99,10 @@ fi
8999
# --- Templates[] (one per product_id) ---------------------------------------
90100
TEMPLATES="$(manifest_product_ids "$MANIFEST" | jq -R . | jq -s \
91101
--argjson params "$TEMPLATE_PARAMS_JSON" \
92-
'[.[] | {ProductID: ., CertificateProfile: ., Parameters: $params}]')"
102+
--argjson codes "$PRODUCT_CODE_MAP_JSON" \
103+
'[.[] | . as $p
104+
| {ProductID: $p, CertificateProfile: $p,
105+
Parameters: ($params + (if $codes[$p] then {ProductCode: $codes[$p]} else {} end))}]')"
93106

94107
# --- Assemble configuration body --------------------------------------------
95108
BODY="$(jq -n \

scripts/register/README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,35 @@ make register-enrollment # stage 06: patterns + KeyRetention=Indefinite
8787

8888
Per-stage env knobs are documented in each script's header comment.
8989

90+
## Stage 02 — gateway CA config (verified 2026-06-09)
91+
92+
The gateway CA config (`PUT /<instance>/config/configuration`) is what maps each
93+
product to a certificate profile so enrollment can resolve a CA. Two things bite:
94+
95+
- **Product codes are per-environment.** The plugin's built-in `DefaultProductCodes`
96+
are PRODUCTION codes (e.g. `DV SSL``838`). A sandbox account has different
97+
numeric codes (e.g. `842``851`) and the gateway validates them at PUT time —
98+
you'll get `Profile '838' was not found in CERTInext. Available profiles: …`.
99+
Set `PRODUCT_CODE_MAP_JSON` (product_id → code) so each `Templates[].Parameters`
100+
carries the right `ProductCode`. Discover codes via `scripts/get-product-details.sh`.
101+
Product **IDs/names** are stable across environments; only the numeric codes differ.
102+
- **`SignerPlace` is required by CERTInext** for every order. It has no fallback
103+
(unlike `SignerIp`, which defaults to `127.0.0.1`). If it's absent the order
104+
fails with a generic `certificate request failed … see CA logs`. Provide it via
105+
`CERTINEXT_SIGNER_PLACE` (the test fixture uses `"Gateway"`); the stage assembles
106+
it into `CAConnection`.
107+
- The gateway has **no GET** for `/config/configuration` (405, POST/PUT only) — it's
108+
not introspectable, so a PUT sends the FULL object. Stage 02 rebuilds `CAConnection`
109+
from the `CERTINEXT_*` env vars; make sure those match the account the CA uses, or
110+
you'll change the live connection. (A successful PUT means the creds validated.)
111+
112+
```sh
113+
export GATEWAY_LOGICAL_NAME=CertiNext # the live CA's LogicalName
114+
export CERTINEXT_SIGNER_PLACE=Gateway
115+
export PRODUCT_CODE_MAP_JSON='{"DV SSL":"842","OV SSL":"846", ...}'
116+
make register-ca-config
117+
```
118+
90119
## Stage 06 — Command EnrollmentPatterns schema (verified 2026-06-09)
91120

92121
The `/KeyfactorProxy/EnrollmentPatterns` (API v1) POST body that works — the stub

0 commit comments

Comments
 (0)