Skip to content

Commit 1251258

Browse files
committed
chore(scripts): add get-dcv/verify-dcv probe scripts and Makefile targets
Add scripts/get-dcv.sh and scripts/verify-dcv.sh mirroring the track-order.sh pattern. Both scripts source ~/.env_certinext and certinext-auth.sh, accept ORDER_NUMBER, DOMAIN_NAME, and optional DCV_METHOD (default 1=DNS TXT), and use jq --arg for safe JSON construction to prevent injection via user-supplied values. Add get-dcv and verify-dcv Makefile targets with DCV_METHOD variable and register both in .PHONY.
1 parent ef692b2 commit 1251258

3 files changed

Lines changed: 99 additions & 0 deletions

File tree

Makefile

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ REPORT_DIR := /tmp/certinext-coverage-report
1818
get-order-report orders \
1919
track-order get-order \
2020
get-certificate get-cert \
21+
get-dcv \
22+
verify-dcv \
2123
generate-order \
2224
revoke-order \
2325
submit-csr \
@@ -203,6 +205,31 @@ track-order get-order:
203205
get-certificate get-cert:
204206
@ORDER_NUMBER=$(ORDER_NUMBER) scripts/get-certificate.sh
205207

208+
# ---------------------------------------------------------------------------
209+
# GetDcv — POST {baseURL}GetDcv
210+
# Fetches the DCV token for a domain on an existing order
211+
# Mirrors ICERTInextClient.GetDcvAsync
212+
# Required: ORDER_NUMBER=<order number> DOMAIN_NAME=<domain>
213+
# Optional: DCV_METHOD=1 (1=DNS TXT, 2=HTTP file, 3=Email; default 1)
214+
# ---------------------------------------------------------------------------
215+
216+
DCV_METHOD ?= 1
217+
218+
get-dcv:
219+
@ORDER_NUMBER=$(ORDER_NUMBER) DOMAIN_NAME=$(DOMAIN_NAME) DCV_METHOD=$(DCV_METHOD) scripts/get-dcv.sh
220+
221+
# ---------------------------------------------------------------------------
222+
# VerifyDcv — POST {baseURL}VerifyDcv
223+
# Instructs CERTInext to check the published DCV token for a domain
224+
# Mirrors ICERTInextClient.VerifyDcvAsync
225+
# Call after publishing the TXT record and allowing time for DNS propagation.
226+
# Required: ORDER_NUMBER=<order number> DOMAIN_NAME=<domain>
227+
# Optional: DCV_METHOD=1 (default 1 = DNS TXT)
228+
# ---------------------------------------------------------------------------
229+
230+
verify-dcv:
231+
@ORDER_NUMBER=$(ORDER_NUMBER) DOMAIN_NAME=$(DOMAIN_NAME) DCV_METHOD=$(DCV_METHOD) scripts/verify-dcv.sh
232+
206233
# ---------------------------------------------------------------------------
207234
# GenerateOrderSSL — POST {baseURL}GenerateOrderSSL
208235
# Places a new SSL/TLS certificate order — mirrors ICERTInextClient.PlaceOrderAsync

scripts/get-dcv.sh

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/usr/bin/env bash
2+
# Required env vars: ORDER_NUMBER, DOMAIN_NAME
3+
# Optional: DCV_METHOD (default: 1 = DNS TXT record)
4+
set -euo pipefail
5+
. ~/.env_certinext
6+
. "$(dirname "$0")/lib/certinext-auth.sh"
7+
8+
ORDER_NUMBER="${ORDER_NUMBER:?Usage: ORDER_NUMBER=<order> DOMAIN_NAME=<domain> [DCV_METHOD=1] scripts/get-dcv.sh}"
9+
DOMAIN_NAME="${DOMAIN_NAME:?DOMAIN_NAME is required}"
10+
DCV_METHOD="${DCV_METHOD:-1}"
11+
12+
read -r ts txn authKey <<< "$(certinext_meta)"
13+
14+
# SOC2 CC6.1: do NOT echo authKey — it is a valid single-use request authenticator.
15+
echo "GetDcv orderNumber=$ORDER_NUMBER domainName=$DOMAIN_NAME dcvMethod=$DCV_METHOD ts=$ts txn=$txn"
16+
17+
# SOX CC6.6: use jq --arg to safely interpolate all user-supplied values into the JSON body,
18+
# preventing shell injection via specially crafted ORDER_NUMBER or DOMAIN_NAME values.
19+
jq -n \
20+
--arg ver "1.0" \
21+
--arg ts "$ts" \
22+
--arg txn "$txn" \
23+
--arg acct "$CERTINEXT_ACCOUNT_NUMBER" \
24+
--arg authKey "$authKey" \
25+
--arg email "$CERTINEXT_REQUESTOR_EMAIL" \
26+
--arg order "$ORDER_NUMBER" \
27+
--arg domain "$DOMAIN_NAME" \
28+
--arg method "$DCV_METHOD" \
29+
'{
30+
meta: {ver: $ver, ts: $ts, txn: $txn, accountNumber: $acct, authKey: $authKey},
31+
dcvDetails: {requestorEmail: $email, orderNumber: $order, domainName: $domain, dcvMethod: $method}
32+
}' \
33+
| curl -s -X POST "$CERTINEXT_API_URL/GetDcv" \
34+
-H "Content-Type: application/json" \
35+
--data-binary @- \
36+
| jq .

scripts/verify-dcv.sh

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/usr/bin/env bash
2+
# Required env vars: ORDER_NUMBER, DOMAIN_NAME
3+
# Optional: DCV_METHOD (default: 1 = DNS TXT record)
4+
set -euo pipefail
5+
. ~/.env_certinext
6+
. "$(dirname "$0")/lib/certinext-auth.sh"
7+
8+
ORDER_NUMBER="${ORDER_NUMBER:?Usage: ORDER_NUMBER=<order> DOMAIN_NAME=<domain> [DCV_METHOD=1] scripts/verify-dcv.sh}"
9+
DOMAIN_NAME="${DOMAIN_NAME:?DOMAIN_NAME is required}"
10+
DCV_METHOD="${DCV_METHOD:-1}"
11+
12+
read -r ts txn authKey <<< "$(certinext_meta)"
13+
14+
# SOC2 CC6.1: do NOT echo authKey — it is a valid single-use request authenticator.
15+
echo "VerifyDcv orderNumber=$ORDER_NUMBER domainName=$DOMAIN_NAME dcvMethod=$DCV_METHOD ts=$ts txn=$txn"
16+
17+
# SOX CC6.6: use jq --arg to safely interpolate all user-supplied values into the JSON body,
18+
# preventing shell injection via specially crafted ORDER_NUMBER or DOMAIN_NAME values.
19+
jq -n \
20+
--arg ver "1.0" \
21+
--arg ts "$ts" \
22+
--arg txn "$txn" \
23+
--arg acct "$CERTINEXT_ACCOUNT_NUMBER" \
24+
--arg authKey "$authKey" \
25+
--arg email "$CERTINEXT_REQUESTOR_EMAIL" \
26+
--arg order "$ORDER_NUMBER" \
27+
--arg domain "$DOMAIN_NAME" \
28+
--arg method "$DCV_METHOD" \
29+
'{
30+
meta: {ver: $ver, ts: $ts, txn: $txn, accountNumber: $acct, authKey: $authKey},
31+
dcvDetails: {requestorEmail: $email, orderNumber: $order, domainName: $domain, dcvMethod: $method}
32+
}' \
33+
| curl -s -X POST "$CERTINEXT_API_URL/VerifyDcv" \
34+
-H "Content-Type: application/json" \
35+
--data-binary @- \
36+
| jq .

0 commit comments

Comments
 (0)