Huawei Cloud SCM Certificate List
Overview
Inventory the SSL/TLS certificates managed by Huawei Cloud SCM in one region
through KooCLI hcloud SCM ListCertificates, returning certificate name, ID,
bound domain (and SANs), type family (DV/OV/EV), status, expiry time, remaining
days, derived source and the region. Aimed at certificate inventory (证书盘点),
expiry patrol (到期巡检), deployment pre-check (部署前核对) and compliance review.
| Operation | REST path | Method | Purpose |
|---|---|---|---|
SCM ListCertificates |
/v3/scm/certificates |
GET | list SCM certificates of the region |
The REST path is verified from the official SDK source (
huaweicloudsdkscm/v3/scm_client.py,_list_certificates_http_info→resource_path = "/v3/scm/certificates"), not inferred.
Architecture:
agent → python3 scripts/list_scm_certs.py [--region=<region>] [--table|--json]
→ hcloud SCM ListCertificates --cli-region=<region> --limit=<n> --offset=<m>
└─ (hcloud missing / failed) → huaweicloudsdk SCM SDK ListCertificates
→ Huawei Cloud SCM OpenAPI → parsed JSON → compact list / table / JSON
Key properties:
- Read-only by design — only
ListCertificatesis ever constructed; the write-intent guard rejects--action create|delete|update|import|push|...(and a write keyword passed as the search content) before any command runs. Certificate application, purchase, import, deployment push, revocation and deletion are explicitly out of scope and require a dedicated write-capable skill with explicit user confirmation. - CLI first, SDK fallback —
hcloudis the primary path; when it is missing or fails with a transient/backend error the script falls back tohuaweicloudsdkscm(SDK credentials come fromHUAWEICLOUD_SDK_AK/HUAWEICLOUD_SDK_SKonly; SCM is a global service, so the SDK client is built withGlobalCredentials, optionally seeded byHUAWEICLOUD_SDK_DOMAIN_ID).403, credential and[USE_ERROR]failures never fall back — they are reported as-is so a permission problem is never silently turned into "no certificates". - Complete inventory — offset+limit paging until a short page or
total_countis reached, with--max-pagesas a safety cap. - Precise expiry filter —
--expiring Nis a client-side filter on the computeddays_left(≤ N, including already expired certificates), so it is exact regardless of the server-sideexpired_days_sincesemantics. - No files written — everything goes to stdout; secrets are delegated to the KooCLI profile or environment.
- Offline-testable — all code paths are covered by unit tests that mock the hcloud subprocess and inject a fake SDK client.
Out of scope: applying for / buying / importing / pushing / deploying / revoking
/ deleting / updating certificates, CSR management, private CA management,
ShowCertificate deep-dive, cross-region aggregation and file export.
Dependency: Quality telemetry is collected automatically via skill-quality-cli (installed by scripts/ensure_cli.sh if absent).
Prerequisites
- KooCLI (
hcloud) installed — see references/cli-installation-guide.md. Missing hcloud is not fatal: the script falls back to the SDK. - Active credential profile — configure credentials out-of-band (run the
KooCLI configure command in your terminal, or export
HUAWEICLOUD_SDK_AK/HUAWEICLOUD_SDK_SK). Never paste AK/SK into chat; the script never reads, echoes, or stores secrets itself. - IAM permission — read-only
scm:cert:list(certificate list); least-privilege policy in references/iam-policies.md. - Python 3.8+ — standard library only for the CLI path; the SDK fallback
additionally needs
huaweicloudsdkcore+huaweicloudsdkscm. - Outbound HTTPS access to
*.myhuaweicloud.com. skill-quality-cli— ensured bybash scripts/ensure_cli.sh(idempotent, skips if present).- Upgrade: run
skill-quality-cli upgrademanually (no auto-upgrade) - Disable telemetry report: set
SKILL_QUALITY_REPORT=0
- Upgrade: run
Workflow
- Confirm the region (default
cn-north-4) — SCM certificates are region-scoped; SCM endpoints exist incn-north-4,ap-southeast-1andmy-kualalumpur-1per the SDK region table. - Run the list script with the desired output mode and filters.
- Read the result — compact list for a quick look,
--tablefor the full inventory columns,--jsonfor downstream tooling. - Handle the empty / error cases per the Edge Cases table (the script prints an explicit, actionable hint for each of them).
Core Commands
⚠️ Mandatory: every
hcloudcommand in this skill MUST be wrapped withskill-quality-cli run --skill-name huawei-cloud-scm-cert-list --— barehcloudcalls are strictly forbidden.
# Primary path: read-only certificate list (one page, default compact output)
skill-quality-cli run --skill-name huawei-cloud-scm-cert-list -- \
hcloud SCM ListCertificates --cli-region=cn-north-4 --limit=50 --offset=0
# Fuzzy search by certificate name or bound domain
skill-quality-cli run --skill-name huawei-cloud-scm-cert-list -- \
hcloud SCM ListCertificates --cli-region=cn-north-4 --limit=10 --content=example
# Server-side "within validity or expiring in N days"
skill-quality-cli run --skill-name huawei-cloud-scm-cert-list -- \
hcloud SCM ListCertificates --cli-region=cn-north-4 --limit=50 --expired_days_since=30
# Confirm the operation really exists (read-only help)
skill-quality-cli run --skill-name huawei-cloud-scm-cert-list -- \
hcloud SCM ListCertificates --cli-region=cn-north-4 --help
# Wrapper script (do the paging / filtering / rendering for you)
python3 scripts/list_scm_certs.py --region cn-north-4
python3 scripts/list_scm_certs.py --table --region cn-north-4
python3 scripts/list_scm_certs.py --json --region cn-north-4
python3 scripts/list_scm_certs.py --content example.com --region cn-north-4
python3 scripts/list_scm_certs.py --expiring 30 --region cn-north-4
python3 scripts/list_scm_certs.py --backend sdk --region cn-north-4
# Quality-CLI readiness + offline unit tests
bash scripts/ensure_cli.sh
python3 -m unittest discover -s tests -v
Output examples
Default (compact):
证书名称 | 绑定域名 | 到期时间
-----------------+------------------+-------------------
prod-web | www.example.com | 2026-12-31 08:00:00
共 1 个证书(区域: cn-north-4,后端: cli,来源: SCM签发 1)
--table (exactly eight columns):
证书ID | 名称 | 域名 | 类型 | 状态 | 到期时间 | 剩余天数 | region
--json prints the merged raw response with certificates, total_count and
region.
Field normalization / derivation
| Field | Source | Notes |
|---|---|---|
id / name / domain / sans |
API as-is | - when the API omits it |
type |
API type (DV_SSL_CERT* → DV, OV_* → OV, EV_* → EV) |
unknown values are shown verbatim |
status |
API status as-is |
e.g. ISSUED, UPLOAD, EXPIRED, REVOKED |
expire_time |
API expire_time, normalized to UTC YYYY-MM-DD HH:MM:SS |
- when missing |
days_left |
derived from expire_time vs. now |
negative for expired certificates |
source |
derived from status (no fabricated API field) |
UPLOAD → 上传托管; SCM lifecycle statuses → SCM签发; otherwise - |
region |
--region |
single region per call |
Parameter Confirmation
| Parameter | Required | Description | Example |
|---|---|---|---|
--region |
No | Huawei Cloud region of the SCM certificates (default cn-north-4) |
cn-north-4 |
--content |
No | Fuzzy search by certificate name / bound domain / SAN (passed to the API, re-checked client-side) | example.com |
--expiring |
No | Client-side filter: only certificates with days_left <= N (includes expired) |
30 |
--expired-days-since |
No | Server-side filter: within validity period or expiring in at most N days | 60 |
--enterprise-project-id |
No | Enterprise project ID; omit to query all projects the caller can see | 0 |
--limit |
No | Page size, only 10 / 20 / 50 (default 50) |
50 |
--offset |
No | Starting offset (default 0) |
0 |
--max-pages |
No | Safety cap for automatic paging (default 200) |
20 |
--table |
No | Print the full eight-column table | - |
--json |
No | Print the raw merged response body | - |
--backend |
No | auto (CLI → SDK fallback), cli, or sdk |
auto |
--timeout |
No | Per-call timeout in seconds (default 60) |
60 |
--action |
No | Only list is allowed; any other value is rejected by the read-only guard |
list |
KooCLI Command Format Standard
hcloud <Service> <Operation> --cli-region=<region> [--key=value ...]
| Element | Value (verified from hcloud SCM ListCertificates --help) |
Example |
|---|---|---|
| Service | SCM (title case) |
SCM |
| Operation | ListCertificates (PascalCase, GET) |
ListCertificates |
| Region | --cli-region=<region> is required |
--cli-region=cn-north-4 |
| Simple parameter | --key=value |
--limit=50 |
Supported query parameters: --content, --limit, --offset,
--expired_days_since, --enterprise_project_id, --status, --deploy_support,
--owned_by_self, --sort_dir, --sort_key. This skill only uses the read-only
subset listed under Parameter Confirmation and never sends a mutating request.
Edge Cases
| Scenario | Handling |
|---|---|
| Account has no certificates | prints 未找到 SSL 证书(区域: …) plus a region hint, exit 0 |
| Filters match nothing | prints 未找到匹配的 SSL 证书(区域: …) plus a filter hint, exit 0 |
403 / SCM.4002 / not authorized |
explicit hint to grant scm:cert:list, exit 1 (never shown as an empty list) |
| Missing / invalid AK/SK | explicit hint to configure the KooCLI profile or export env vars, exit 1 |
| Network failure / timeout | explicit network hint, exit 1; CLI path falls back to the SDK in auto mode |
[USE_ERROR] from KooCLI |
parameter/usage hint (region, limit, offset), exit 1 |
| hcloud not installed | SDK fallback in auto mode; explicit install hint with --backend cli, exit 1 |
huaweicloudsdkscm not installed |
pip install huaweicloudsdkcore huaweicloudsdkscm hint, exit 1 |
Write intent (--action delete, --content import, …) |
rejected before any call, exit 1 |
Invalid --limit / --offset / --expiring |
rejected with the valid range, exit 1 |
Reference Documents
- references/iam-policies.md — least-privilege read-only IAM policy (
scm:cert:list) - references/cli-installation-guide.md — KooCLI install, credential setup, SDK fallback
- references/verification-method.md — how to verify each output mode and error path
- references/acceptance-criteria.md — acceptance checklist
- references/dataflow-diagram.md — Mermaid data flow diagram
