# Certificate Decoder

> 在瀏覽器中解碼 X.509 憑證與 CSR：到期倒數、SAN 清單、金鑰用途、指紋、憑證鏈完整性診斷，以及憑證與私鑰的配對檢查。貼上的內容不會離開你的裝置。

- URL: https://bytescope.dev/zh-Hant/certificate-decoder/
- Locale: zh-Hant · Also: [en](https://bytescope.dev/en/certificate-decoder.md) · [ja](https://bytescope.dev/ja/certificate-decoder.md)
- Runs: 檔案不會離開你的瀏覽器 — 全部在本機處理。
- Requires: Any modern browser (Chrome, Edge, Firefox, Safari), desktop and mobile.
- Updated: 2026-09-08

## What it does

貼上或拖入 PEM、DER、CRT 或 CER 內容 — 單一憑證、整條憑證鏈，或一份 CSR — 每個欄位都會立即解碼：逐一拆解主體與簽發者 DN、附剩餘天數倒數的有效期限（已過期以洋紅色標示，少於 30 天以橘色標示，因為到期通常正是你來這裡要檢查的）、完整的 SAN 清單、金鑰用途與延伸金鑰用途、公鑰類型與長度、簽章演算法、序號，以及 SHA-1／SHA-256 指紋。

把好幾張憑證一起貼上，工具會把它們排成一條憑證鏈、逐環驗證，並用一句話診斷出經典的伺服器設定錯誤：「缺少中繼憑證」。憑證與金鑰的配對器接收一張憑證和一把私鑰，告訴你兩者是不是一組 — 也就是在服務中斷時「這到底是不是正確的金鑰？」這個問題的五秒解答。主機名稱檢查會把你輸入的網域與 SAN 清單比對，弱簽章（SHA-1）和自簽憑證也都會被特別標示出來。

所有解析都透過 WebCrypto 在你的瀏覽器中進行 — 憑證、CSR，尤其是私鑰，絕不會被傳送到任何地方。把私鑰貼進一個來路不明的網站通常是資安上的失誤；在這裡，架構本身讓它是安全的，你甚至可以拔掉網路線來證明這一點。

它也能解開 PKCS#12 容器：拖入一個 .p12 或 .pfx 檔、輸入匯出密碼，憑證鏈與私鑰就會直接被取出來 — 憑證會流進同一套完整解碼器、私鑰會與葉憑證比對，而且全部都能下載成 PEM。這裡舊格式檔案特別重要：來自舊版 OpenSSL、Java keytool 與 Windows 匯出的容器，使用的是瀏覽器 WebCrypto 無法處理的 RC2-40 與 3DES 加密，因此由內建的 JavaScript 實作負責解密，而私鑰依然不會離開這個分頁。

## Limits

Does not fetch certificates from a live server or validate the chain against a trust store; paste or drop the certificate.

## Machine output

Copy JSON copies an envelope `{ tool, url, generatedAt, userAgentHint, result }`. `tool` is `"certificate-decoder"`; `result` is the on-screen decode below. This page does not contact any host and does not consult a system trust store, so no field here means "trusted". It decodes what was pasted, compares `notBefore`/`notAfter` against the clock, and checks the signatures between the pasted certificates — nothing else. Private-key PEM, raw PEM/DER, PKCS#12 passwords, and the dropped file name are omitted.

- `certificates` (array of objects) — Decoded certificates in paste/drop order. Each has `commonName` (or `null`), `subjectDn`, `issuerDn`, `subject` / `issuer` (DN components `{ oidName, value }`), `serialHex`, `notBefore` / `notAfter` (ISO 8601 UTC), `daysRemaining`, `validityWindow` (`"current"` | `"expiring-soon"` | `"expired"` | `"not-yet-valid"`, or `null` if the page did not classify it — a calendar comparison only, and never a statement that the certificate is trusted, unrevoked, or correctly issued), `signatureAlgorithm`, `signatureHash`, `publicKey` (`type`, `size` or `null`, `curve` or `null`, `algorithm`), `sans` (`{ type, value }`), `keyUsage`, `extendedKeyUsage`, `basicConstraints` (`null` = extension absent; otherwise `{ isCA, pathLen }` with `pathLen` `null` when unset), `subjectKeyId` / `authorityKeyId` (lowercase hex or `null`), `isSelfSigned` (the certificate signs itself), `fingerprints` (`sha1`, `sha256` lowercase hex), `weaknesses` (on-screen warning strings).
- `csrs` (array of objects) — Decoded CSRs in paste/drop order. Each has `commonName` (or `null`), `subjectDn`, `subject`, `sans`, `publicKey`, `signatureAlgorithm`, `signatureHash`, `signatureValid` (boolean — proof of possession: the request is signed by the key it carries. It is not a statement about any CA accepting the request).
- `chain` (object | null) — What the pasted certificates amount to when ordered leaf-first. `null` = assembly was not run (fewer than two certificates). When present: `diagnosis` — `"self-contained"` (every issuer needed was pasted, up to a self-signed top), `"missing-issuer"` (an issuer was not among them; see `missingIssuerDn`), `"signature-mismatch"` (a child's signature does not check out against the issuer that was pasted). `rootIsSelfSigned`, `missingIssuerDn` (or `null`), `subjects` (on-screen CN/DN labels, leaf first), `links` (`{ childDn, issuerDn, signatureMatchesIssuer }` — the signature check between two pasted certificates, not a path validation). `"self-contained"` says the pasted bundle hangs together; it does not say any client would accept it.
- `skippedReasons` (string[]) — Why a PEM/DER block was skipped, on-screen order. Block labels are omitted because a dropped file name is used as the label.

## FAQ

### 在這裡貼上私鑰安全嗎？

安全 — 一切都用內嵌在頁面裡的 WebCrypto/ASN.1 函式庫在你的瀏覽器本機解析；沒有任何伺服器呼叫，這點你可以在 DevTools 的 Network 分頁驗證（或在貼上前先離線）。話雖如此，仍請把任何貼上的私鑰當作機密看待：用完就關掉分頁。

### 「缺少中繼憑證」是什麼意思？

瀏覽器信任的是根 CA，但你的伺服器憑證通常是由一個中繼 CA 簽發的。伺服器必須把那張中繼憑證連同自己的憑證一起送出；當它沒這麼做時，有些用戶端會因信任錯誤而失敗，有些卻能正常運作（因為它們快取了那張中繼憑證） — 這正是經典的「在 Chrome 可以、用 curl 卻失敗」症狀。把你的憑證鏈貼進來，工具會精確指出是哪一環缺了。

### 我要怎麼檢查一張憑證和它的私鑰是否相符？

把兩者都貼進配對器。憑證裡含有公鑰；工具會從你的私鑰推導出對應的公鑰再加以比對。不相符就代表這把金鑰無法搭配這張憑證使用 — 這是診斷 nginx「key values mismatch」錯誤最快的方法。

### 在把 CSR 送交給 CA 之前，可以先解碼它嗎？

可以 — 貼上 CSR 即可在送出前檢視主體、要求的 SAN 與金鑰細節。在 CSR 裡抓到打錯的網域，遠比重新簽發一張憑證划算得多。

### 支援哪些格式？

PEM（BEGIN CERTIFICATE／CERTIFICATE REQUEST／PRIVATE KEY 區塊，貼上或拖入皆可）、DER 二進位檔（.crt/.cer/.der）、含多張憑證的 PEM bundle，以及透過專用解包面板處理的 PKCS#12（.pfx/.p12）容器（有密碼保護；憑證鏈與私鑰皆於本機取出）。

### 它能開啟 .p12 / .pfx 檔嗎？

可以。把容器拖進解包面板並輸入密碼：憑證鏈與私鑰會在你的瀏覽器中取出，並透過完整解碼器顯示，私鑰會與葉憑證比對，也可下載成 PEM。由於在解密任何內容之前，會先用容器的完整性 MAC 驗證密碼，因此密碼錯誤會與檔案損毀被清楚區分開來回報。

### 為什麼其他瀏覽器工具打不開的舊 .p12，這裡卻能開？

舊版 OpenSSL、Java keytool 與 Windows 匯出會用 RC2-40 加密憑證、用 3DES 加密私鑰 — 這些是瀏覽器內建 WebCrypto 根本沒有實作的加密演算法，所以純 WebCrypto 的工具會拒絕這些檔案。本工具內建了這些舊式加密演算法的 JavaScript 實作，因此 RC2-40、3DES 以及現代的 AES-256（PBES2）全都能開 — 而私鑰依然不會離開這個頁面。
