Skip to main content
Glama

CipherHUB Cryptography Toolkit

cert_parse

[cert] [x509_certificate] 解析 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 可传多张证书的整链(叶子在前,合计≤32KB),cert_verify 为单张≤10KB

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 头尾,≤10KB)"New value: +"证书的 PEM 文本(含 BEGIN/END CERTIFICATE 头尾);cert_parse 可传多张证书的整链(叶子在前,合计≤32KB),cert_verify 为单张≤10KB"
  2. Added

TDQS

A4.3/5.0
Behavior5/5

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

No annotations are supplied, so the description carries the full behavioral burden and does so: input acceptance rules (PEM single or full chain, leaf first, ≤32KB), the auto-detection rule for the GM branch (signature OID under 1.2.156.10197), the exact can_sign_child logic with an RFC 5280 citation and its edge case (missing keyUsage is not a restriction), the fact that chain linkage is structural only and not signature validation, and the failure mode ('Certificate parse failed'). It even discloses the underlying implementations (cryptography for the international path, GmSSL C library for SM2 points).

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?

The purpose and limits are front-loaded, which is good, but the body is a single dense paragraph that enumerates every returned field in a run-on list. Much of that enumeration is justified because there is no output schema, yet the lack of any structural separation makes it hard to scan and pushes it well past the minimum useful length.

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 no annotations for a fairly complex tool, the description compensates fully: it documents return-field families for both single-cert and chain output, the meaning of chain_linkage states, the dual SHA-256/SM3 fingerprints, the GM-only SM2 public key encodings with exact lengths, and the error condition. An agent can predict the response shape without an output schema.

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

Parameters3/5

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

There is a single parameter and schema coverage is 100%, with the schema already stating the PEM framing and the 32KB multi-cert allowance, so the baseline is 3. The description reinforces leaf-first ordering and the failure condition but adds little syntax or formatting detail the schema does not already carry.

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?

The description opens with a specific verb and resource (parse an X.509 certificate or chain), names both code paths it covers (international X.509 and GM/SM2), and states the scope precisely — leaf-first multi-cert PEM up to 32KB, with top-level fields describing the first certificate. This is far beyond restating the name and lets an agent distinguish it from sibling parsers immediately.

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?

It explicitly routes structural-only work here and signature verification to cert_verify ("结构展示,不含签名验证;逐级签名验证用 cert_verify"), and the schema note adds the size distinction (chain ≤32KB here vs single ≤10KB for cert_verify). What it lacks is an explicit "use this when / do not use when" framing against other parse siblings, so it stops just short of a 5.

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.