Skip to main content
Glama

CipherHUB Cryptography Toolkit

cert_parse

Read-only

[cert] 解析 X.509 证书或证书链(国际 / 国密 GM SM2 双路径)。输入 PEM:单张证书,或多张证书的整链(叶子在前,合计≤32KB)。顶层字段始终描述第一张(叶子)证书:证书类型(X.509 (international) / X.509 (GM SM2),按签名算法 OID 是否落在国密分支 1.2.156.10197 自动判定)、版本、序列号 hex、签名算法及 OID、颁发者/主体 DN(dict 与 RFC4514 串)、有效期(UTC ISO-8601)与当前状态(valid/expired/not_yet_valid,仅信息展示)、是否自签、基本约束(is_ca、path_length、basic_constraints_present)、密钥用途(key_usage 名称列表、key_usage_present)、能否签发子证书(can_sign_child)、SKI/AKI(大写冒号 hex)、SAN、扩展清单(oid/name/critical,SKI/AKI/BasicConstraints/KeyUsage/SAN 附可读值 value)、SHA-256 与 SM3 双指纹。链级字段:chain_cert_count(证书张数)、certificate_chain(逐级条目:index、证书类型、版本、主体/签发方 DN、序列号、签名算法及 OID、公钥类型/位数/曲线、有效期与状态、是否自签、基本约束与密钥用途、can_sign_child、SKI/AKI、aki_matches_next(本张 AKI 是否等于下一张 SKI,任一侧缺失为 null)、issued_by_next(本张签发方 DN 是否等于下一张主体 DN)、SAN、扩展清单、双指纹,GM 条目附 SM2 公钥两种编码)、chain_linkage(single_cert / linked_to_root / linked_open_ended / linkage_broken)。can_sign_child 判定:basicConstraints 为 CA:TRUE,且 keyUsage 存在时必须含 keyCertSign(RFC 5280 4.2.1.3;keyUsage 缺失不构成限制)。链衔接按相邻证书的签发方 DN 与下一张主体 DN 是否相等判定(结构展示,不含签名验证;逐级签名验证用 cert_verify)。GM 证书顶层额外返回主体 SM2 公钥:sm2_public_key_hex(裸坐标 X||Y,128 hex 字符)与 sm2_public_key_hex_uncompressed(未压缩点 04||X||Y,130 hex 字符,与 gmssl certparse 的 ECPoint 输出一致)。国际路径 cryptography 实现,SM2 公钥点位走 GmSSL C 库。解析失败(非法 PEM/DER)返回错误码 'Certificate parse failed'。

Tool call template

This tool declares no required parameters. Add optional parameters from the input schema as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {},
    "name": "cert_parse"
  }
}

Input Schema

NameRequiredDescriptionDefault
certificate_in_pemNo证书的 PEM 文本(含 BEGIN/END CERTIFICATE 头尾);cert_parse 与 cert_verify 均可传多张证书:第一张为待验证证书,其后的中间证书作为候选(叶子在前,合计≤32KB)

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changed
    • changedInput schema / properties / certificate_in_pem / description
      Previous value: -"证书的 PEM 文本(含 BEGIN/END CERTIFICATE 头尾);cert_parse 可传多张证书的整链(叶子在前,合计≤32KB),cert_verify 为单张≤10KB"New value: +"证书的 PEM 文本(含 BEGIN/END CERTIFICATE 头尾);cert_parse 与 cert_verify 均可传多张证书:第一张为待验证证书,其后的中间证书作为候选(叶子在前,合计≤32KB)"
  2. Changed1 schema field changed
    • changedInput schema / properties / certificate_in_pem / description
      Previous value: -"终端实体证书的 PEM 文本(含 BEGIN/END CERTIFICATE 头尾,≤10KB)"New value: +"证书的 PEM 文本(含 BEGIN/END CERTIFICATE 头尾);cert_parse 可传多张证书的整链(叶子在前,合计≤32KB),cert_verify 为单张≤10KB"
  3. Added

TDQS

A4.3/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare readOnlyHint=true and openWorldHint=false, so the safety profile is covered; the description goes further by disclosing the 32KB input limit, the informational-only nature of the valid/expired/not_yet_valid status, that chain linkage is structural and does not verify signatures, and the exact error string 'Certificate parse failed' on malformed PEM/DER. It also notes the split implementation (cryptography for international, GmSSL C library for SM2 point decoding), which explains potential behavioral differences, though it does not discuss performance or caching.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Front-loaded correctly with purpose, but the bulk is an exhaustive field-by-field enumeration of the return payload that reads like a specification dump. Since no output schema exists, much of this content is justified, but the single dense paragraph packs multiple distinct ideas together and would benefit from structure and trimming of redundant qualifiers.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

With no output schema and only one parameter, the description carries the full burden and delivers: input format and constraints, top-level versus chain-level return fields, the can_sign_child decision rule with RFC citation, linkage semantics, and error behavior. An agent can call this tool correctly without opening anything else.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema has 100% coverage for the single parameter, so the baseline is 3. The description adds real meaning beyond the schema by explaining the chain semantics of the parameter (first certificate is the leaf, following entries are candidate intermediates, leaf-first ordering, total ≤32KB), which the schema only partially echoes.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Opens with a specific verb and resource ("解析 X.509 证书或证书链") and immediately scopes the scope with the dual international/GM SM2 path and the fact that top-level fields always describe the leaf certificate. It differentiates itself from the sibling cert_verify by stating that structural linkage display is not signature verification.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Gives clear context for invocation: PEM input, single certificate or full chain with leaf first, ≤32KB total, and explicitly routes signature validation to cert_verify. No explicit statement of when NOT to use it, but the alternative is named with the condition that selects it.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.