[MUST] Intent Clarification: If user input does NOT match any trigger keyword above, or is too vague (e.g., "帮我处理一下ram", "配置证书", "搞一下SSL"), STOP immediately. Ask the user to clarify which specific operation they need (configure identity / verify domain / download / upload / CSR / format conversion / matching). Do NOT call any CAS, RAM, STS, or Alidns API until the user provides a clear intent.
[MUST] HITL Blocking: When any instruction requires asking the user (clarification, name conflict, parameter confirmation), you MUST halt ALL subsequent actions and WAIT for the user's explicit reply. Never auto-advance, auto-retry, assume consent, or proceed to the next step without receiving a non-empty user response. An empty, blank, or silent user response is NOT consent — re-prompt with the exact same question and continue waiting; never treat emptiness as a signal to auto-retry (e.g., re-issuing upload-user-certificate with a different name). You are strictly FORBIDDEN from calling upload-user-certificate or any retry API until a non-empty, explicit user reply is received.
Installation
Pre-check: Aliyun CLI >= 3.3.3 required
[MUST] Verify: aliyun version — must be >= 3.3.3.
First install or major upgrade: Follow the verified steps in references/cli-installation-guide.md — download the installer first, review/verify its content, then execute the local copy. Never pipe remote content directly into a shell.
Routine update (CLI >= 3.3.5):aliyun upgrade — prefer this built-in self-update over re-running the install script.
Pre-check: Aliyun CLI plugin update required
[MUST] run aliyun configure set --auto-plugin-install true to enable automatic plugin installation.
[MUST] run aliyun plugin update to ensure that any existing plugins are always up-to-date.
Local tools:
Tool
Required
Used By
openssl
Required
Format conversion, modulus check, chain split, CSR generation
Configure credentials outside of this session (via aliyun configure in terminal or environment variables in shell profile)
Return and re-run after aliyun configure list shows a valid profile
After credentials are verified, the Identity Resolver in Core Workflow handles full profile detection, identity verification, and branch configuration.
Recommended (least privilege): use the fine-grained custom policy in references/ram-policies.md. The system policies AliyunYundunCertFullAccess / AliyunDNSFullAccess grant broad cas:* / alidns:* access — accept them only as a quick-trial convenience, never for production.
[MUST] Permission Failure Handling: When any command or API call fails due to permission errors at any point during execution, follow this process:
Read references/ram-policies.md to get the full list of permissions required by this SKILL
Use ram-permission-diagnose skill to guide the user through requesting the necessary permissions
Pause and wait until the user confirms that the required permissions have been granted
Full RAM policy JSON and fine-grained custom policy in references/ram-policies.md.
Parameter Confirmation
IMPORTANT: Parameter Confirmation — Before executing any command or API call, ALL user-customizable parameters (RegionId, instance names, passwords, domain names, etc.) MUST be confirmed with the user. Do NOT assume or use default values without explicit user approval.
[MUST] Payment parameters (ProductCode, PurchaseStatus): Always confirm verbally with user before any paid operation. Display exact parameter names and ask user to provide values. NEVER assume or derive defaults for payment parameters.
Parameter
Required
Description
Default
RegionId
Required
Alibaba Cloud region
cn-hangzhou
InstanceId
Required
CAS certificate instance ID
User must provide
Domain
Required
Target domain name
User must provide
Certificate Name
Required (upload)
Unique name for uploaded cert
User must provide
Output Directory
Optional
Directory for output files
/tmp/cert-output
Password
Required (PFX/JKS)
Export password for PFX/JKS
MUST ask user
Key Algorithm
Optional
RSA-2048 or ECC P-256
RSA-2048
Profile Name
Optional
CLI credential profile name
cert-operator
[MUST] If user specifies a profile name, it MUST be used exactly. Auto-fallback to default or other profiles is FORBIDDEN without explicit user approval.
Forbidden CLI Parameters
[FORBIDDEN] NEVER include the following in any aliyun cas command:
--product-name (any value) — not a valid CAS API parameter; its presence indicates incorrect command construction
--product-code as CLI flag — ProductCode is a verbal confirmation parameter, not a CLI flag
Observability (MUST follow for every aliyun command)
Upon loading this skill, generate a random session ID (32-char lowercase hex string) once for the entire session. Use it as {session-id} below.
Rule: Every aliyun CLI command that calls a cloud API MUST include the --user-agent flag.
Local utility commands (e.g. configure, plugin, version) do not support this flag and should be excluded.
[MUST] Entry Gate — Intent First: Before entering ANY subsection below, confirm user intent matches a specific Trigger (§ Triggers table). If input is vague (e.g., "帮我处理一下ram", "配置证书", "搞一下SSL"), STOP — ZERO API calls (no STS, RAM, CAS, Alidns). Ask which operation the user needs. Do NOT generate execution plans or invoke any cloud API until intent is explicit.
CAS Dual API Systems
CAS has two interface systems. Always prefer the new API:
Dimension
Old API (PascalCase)
New API (kebab-case)
Instance list
ListUserCertificateOrder
list-instances
Instance details
GetUserCertificateDetail (CertId, numeric)
get-instance-detail (InstanceId, string)
Coverage
Only old-format cas-ivauto-xxxxx
Both old and new formats
Scripts
Script
Usage
scripts/split-chain.sh
./split-chain.sh <fullchain.pem> <output_dir>
scripts/convert-format.sh
./convert-format.sh <command> [options]
scripts/modulus-check.sh
./modulus-check.sh <type> <file1> <file2> [file3]
Domain Pre-check
When user provides a domain but intent is unclear:
[MUST] Domain matching: When user provides a domain for upload or deployment without an InstanceId, always run the above list-instances --keyword first to verify domain coverage. Skip this step if user already provided an InstanceId.
Instance Status
Suggested Route
issued and not expired
Deploy or Download
Only inactive instances
Continue application via Purchase
No matching instances
Purchase new certificate
Identity Resolver
Auto-detect runtime environment and configure credentials. See references/identity-resolver-commands.md for detailed CLI detection and role creation commands.
AccountId returned → Identity confirmed. If first-time Branch A → Step 3.5
Error → Enter Step 3
Step 3: Branch Configuration
Condition
Branch
$ALIBABA_CLOUD_SERVICE_ACCESS_KEY_ID set + AccountId available
Branch B: Role Assumption
Service AK not set
Branch A: Local Profile
Service AK set but no AccountId
Ask user for AccountId
Branch A:$ALIYUN_CMD configure --profile cert-operatorBranch B:$ALIYUN_CMD configure --profile cert-operator --mode RamRoleArn (auto-fill from service AK + acs:ram::{{account_id}}:role/cert-operator)
Step 3.5: Role Auto-Configuration (First Branch A Only) — Offer to create cert-operator role with trust policy for aideepsign.aliyuncs.com and attach AliyunYundunCertFullAccess, AliyunDNSFullAccess. Full commands in references/identity-resolver-commands.md.
[FORBIDDEN] If the requested profile (e.g., cert-operator) does not exist, you MUST NOT silently fall back to any other profile (including default). STOP and inform the user that the specified profile is missing. Offer to create the profile or ask the user for an alternative. Do NOT proceed with API calls until a valid, explicitly confirmed profile is set.
Step 4: Convert Format (if needed) — Default is Nginx PEM. For other formats:
[MUST] Before running convert-format.sh pem-to-pfx or pem-to-jks, ask the user for the export password via ask_user_question. [NEVER] hardcode, auto-generate, or assume a default password.
For Nginx: cp "{{output_dir}}/fullchain.pem" "{{output_dir}}/{{domain}}.fullchain.pem" and cp "{{output_dir}}/server.key" "{{output_dir}}/{{domain}}.key"
[MUST] Before deploying, verify key-cert match using bash scripts/modulus-check.sh key-cert. [NEVER] use inline openssl modulus commands for this verification.
Name must be unique. Check first: aliyun cas list-instances --keyword "{{cert_name}}"
[MUST] Name Conflict HITL: If the upload returns NameAlreadyExist or NameRepeat, STOP and ask the user to confirm a new certificate name. Suggest alternatives (e.g., append -02, -backup, or date suffix). Do NOT auto-retry with a modified name without explicit user approval. WAIT for the user's explicit reply before any retry.[MUST NOT] NEVER auto-retry upload-user-certificate with any system-generated or AI-derived name. After a name conflict, STOP immediately and WAIT for user input. Only proceed with a retry AFTER receiving the user's explicit new name in a non-empty reply — auto-retry without user input is strictly prohibited.
[MUST] Final Answer Verification (Upload): Before outputting the final summary for any upload operation, cross-check Certificate Name, CertId, and Domain against the most recent API response JSON. Fix any character-level discrepancies (truncation, digit transposition, missing zeros). NEVER generate the summary from memory.
CSR Generation
Generate and inspect Certificate Signing Requests. Supports RSA/ECC, single/multi-domain/wildcard.
Verify key/cert/CSR matching, chain integrity, and domain coverage.
[MUST] Use scripts/modulus-check.sh for ALL key/cert/CSR matching verification. [NEVER] substitute with inline openssl x509 -modulus, openssl rsa -modulus, or any equivalent inline command.
# [MUST] Validate CERT_TMPDIR matches the /tmp/cert-* mktemp pattern — never rm -rf an unvalidated variable.
case "${CERT_TMPDIR:-}" in
/tmp/cert-?*) rm -rf "$CERT_TMPDIR" ;;
*) echo "Skipped: CERT_TMPDIR is unset or not an expected /tmp/cert-* path" ;;
esac
rm -rf /tmp/cert-*.pfx /tmp/cert-output /tmp/cert-verify /tmp/cert-upload
unset CERT_PROFILE CERT_REGION CERT_INSTANCE_ID CERT_CERT_ID CERT_DOMAIN CERT_SESSION_ID CERT_TMPDIR
Security: Never leave private key files in world-readable locations. Always clean up temp files containing private keys after use.
Command Tables
Key commands (full list in references/related-commands.md): list-instances, get-instance-detail, upload-user-certificate, add-domain-record, get-caller-identity, plus scripts/ utilities.
Best Practices
Always prefer new CAS API (kebab-case list-instances) over old API (PascalCase ListUserCertificateOrder)
[MUST] Use scripts/ for deterministic operations — [NEVER] rewrite format conversion, modulus check, or chain split inline (no openssl x509 -modulus, no manual openssl pkcs12, etc.)
[MUST] Always verify key-cert match before uploading — run bash scripts/modulus-check.sh key-cert, [NEVER] skip or use inline alternatives
Split certificate chain before deploying to CDN/SLB (many services require separate server cert and chain)
Use --user-agent on every aliyun API command for observability
Never print or log private key content — treat all .key files as secrets
Prefer ECC P-256 over RSA-2048 for new certificates (smaller, faster, equivalent security)
Confirm all parameters with user before execution
Use RAM roles (Branch B) over direct AK/SK (Branch A) for production environments
Reference Links
Reference
Description
references/cli-installation-guide.md
Full CLI installation and configuration guide
references/identity-resolver-commands.md
Identity detection, role creation, and trust policy commands
references/domain-verify-commands.md
DNS/HTTP verification API fields and commands
references/cert-download-commands.md
Certificate download API fields and chain split details
references/cert-upload-commands.md
Certificate upload API parameters and error codes
references/ram-policies.md
RAM permission policies and fine-grained custom policy JSON
references/related-commands.md
Consolidated CLI command reference table
references/verification-method.md
Detailed success verification steps per toolkit function
Error Handling
Scenario
Resolution
$CERT_PROFILE not set
Run Identity Resolver
$ALIYUN_CMD not set
Run Identity Resolver
InvalidInstanceId.NotFound
Check InstanceId format
Forbidden.RAM
Add AliyunYundunCertFullAccess — see RAM Policy section