| Crates.io | cert-dump |
| lib.rs | cert-dump |
| version | 3.0.1 |
| created_at | 2025-10-27 17:50:34.598124+00 |
| updated_at | 2025-10-27 19:43:34.830516+00 |
| description | High-performance X.509 certificate scanner and extractor for binary files |
| homepage | |
| repository | https://github.com/19h/cert-dump |
| max_upload_size | |
| id | 1903446 |
| size | 169,335 |
cert-dump is a command-line utility for scanning binary files and directories to find embedded X.509 certificates. It supports both DER (Distinguished Encoding Rules) and PEM (Privacy-Enhanced Mail) formats, providing detailed certificate information, optional extraction capabilities, and intelligent duplicate detection across multiple files.
cargo install cert-dump
1. Basic Scan (List Only)
Scans a binary file and displays all certificates found, without extraction.
cert-dump firmware.bin
2. Extract All Certificates (DER + PEM)
Extracts certificates to the cert_dump/ directory in both DER and PEM formats.
cert-dump firmware.bin --dump
3. Extract DER Format Only
Extracts only DER-encoded certificates.
cert-dump firmware.bin --dump --der
4. Extract PEM Format Only
Extracts only PEM-encoded certificates.
cert-dump firmware.bin --dump --pem
5. Verbose Output with Custom Directory
Scans with verbose logging and extracts to a custom output directory.
cert-dump firmware.bin -v --dump -o my_certs
6. Force Overwrite
Overwrites existing files in the output directory.
cert-dump firmware.bin --dump --force
7. Recursive Directory Scan
Recursively scans all files in a directory for certificates.
cert-dump -R /path/to/directory
8. Recursive Scan with Extension Filter
Scans only specific file types (e.g., executables, JARs, or certificate files).
cert-dump -R --ext exe,dll,jar,apk,pem,der,crt /path/to/directory
9. Duplicate Detection with Annotation
Finds all certificates but marks duplicates with references to first occurrence.
cert-dump -R --mark-duplicates /path/to/directory
10. Unique Certificates Only
Shows only the first occurrence of each unique certificate (suppresses duplicates).
cert-dump -R --unique-only /path/to/directory
11. Parallel Scanning with Custom Threads
Scans multiple files in parallel for faster processing.
cert-dump -R --threads 8 /large/directory
12. Scan with Symlink Following and Depth Limit
Follows symbolic links and limits recursion depth.
cert-dump -R --follow-symlinks --max-depth 3 /path/to/directory
13. JSON Output for Automated Processing
Outputs results as newline-delimited JSON with duplicate information.
cert-dump -R --json /path/to/directory > results.jsonl
14. SQLite Database Export
Writes all certificates and occurrences to a SQLite database for analysis.
cert-dump -R --sqlite certs.db /path/to/directory
15. Combined JSON and SQLite Output
Outputs JSON to stdout while simultaneously writing to SQLite.
cert-dump -R --json --sqlite certs.db /path/to/directory
16. Query SQLite Results
Example queries for the SQLite database.
# Find all unique certificates
sqlite3 certs.db "SELECT sha256, subject, occurrence_count FROM certificate;"
# Find all occurrences of a specific certificate
sqlite3 certs.db "SELECT path, offset FROM occurrence WHERE sha256='...';"
# Find certificates in a specific file
sqlite3 certs.db "SELECT DISTINCT c.* FROM certificate c JOIN occurrence o ON c.sha256=o.sha256 WHERE o.path LIKE '%filename%';"
17. Certificate Chain Visualization
Display certificates in a tree format showing parent-child signing relationships.
cert-dump -R --tree /path/to/directory
18. Filter and Visualize Certificate Chains
Combine filtering with tree visualization to focus on specific certificate types.
# Show only RSA certificates and their relationships
cert-dump -R --tree --key-algo rsa /path/to/certs
# Visualize only valid certificates
cert-dump -R --tree --valid /path/to/certs
19. Certificate Filtering
Filter certificates by various fields with fuzzy matching and multiple criteria.
# Find all Apple certificates
cert-dump -R --org Apple /System/Library/Keychains
# Find expired RSA certificates
cert-dump -R --expired --key-algo rsa /path/to/certs
# Find certificates from Apple OR Google with EC keys
cert-dump -R --org Apple --org Google --key-algo ec /path
# Find weak certificates (SHA-1 or small key sizes)
cert-dump -R --sig-algo sha1 /path
cert-dump -R --key-algo rsa --key-size 1024 /path
memchr) to efficiently scan large binaries for both DER and PEM certificate formats.--unique-only mode to suppress duplicate output--mark-duplicates mode to annotate duplicates with first-occurrence referencescertificate and occurrence tables for complex queries--json --sqlite for both outputs simultaneously)X.509 is a standard for public key certificates used in TLS/SSL, code signing, and other cryptographic protocols. Certificates bind a public key to an identity and are signed by a Certificate Authority (CA) to establish trust.
DER is a binary encoding format based on ASN.1 (Abstract Syntax Notation One). It provides a canonical way to serialize structured data. X.509 certificates are typically stored and transmitted in DER format.
Structure:
A DER-encoded certificate begins with a SEQUENCE tag (0x30) followed by a length encoding. This tool scans for these patterns and validates them using full X.509 parsing to minimize false positives.
Detection Method:
0x30 (SEQUENCE tag)x509-parserPEM is a Base64-encoded representation of DER data, wrapped with human-readable headers and footers:
-----BEGIN CERTIFICATE-----
MIIDXTCCAkWgAwIBAgIJAKL0UG...
-----END CERTIFICATE-----
Detection Method:
-----BEGIN CERTIFICATE----- markers-----END CERTIFICATE----- markersThis tool recognizes and displays key information for a comprehensive set of cryptographic algorithms:
RSA Variants:
DSA:
Elliptic Curve Cryptography:
Chinese National Standards:
Russian GOST Standards:
Post-Quantum Cryptography (NIST PQC):
Signature Algorithms Recognized:
When run with --dump, cert-dump creates files in the specified output directory:
cert.0.der, cert.0.pem: First certificate (both formats by default)cert.1.der, cert.1.pem: Second certificateUse --der or --pem flags to restrict output to a single format.
cert-dump supports comprehensive certificate filtering based on various fields. All filters use fuzzy matching (case-insensitive, substring search) and can be specified multiple times for OR logic.
Distinguished Name (DN) Fields:
| Flag | Description | Example |
|---|---|---|
--org <ORG> |
Organization (O) | --org Apple --org Microsoft |
--ou <OU> |
Organizational Unit (OU) | --ou Engineering |
--common <COMMON> |
Common Name (CN) | --common "*.apple.com" |
--country <COUNTRY> |
Country (C) | --country US --country GB |
--locality <LOCALITY> |
Locality (L) | --locality "San Francisco" |
--state <STATE> |
State/Province (ST) | --state California |
--subject <TEXT> |
Full Subject DN | --subject "Apple Inc" |
--issuer <TEXT> |
Full Issuer DN | --issuer "DigiCert" |
Certificate Identifiers:
| Flag | Description | Example |
|---|---|---|
--serial <SERIAL> |
Serial number (hex substring) | --serial 1A2B3C |
--sha256 <HASH> |
SHA-256 fingerprint (substring) | --sha256 da98f640 |
Cryptographic Algorithms:
| Flag | Description | Example |
|---|---|---|
--key-algo <ALGO> |
Public key algorithm | --key-algo rsa, --key-algo ec |
--sig-algo <ALGO> |
Signature algorithm | --sig-algo sha256, --sig-algo ecdsa |
--key-size <BITS> |
Public key size in bits | --key-size 2048 --key-size 4096 |
Validity Period:
| Flag | Description |
|---|---|
--expired |
Show only expired certificates |
--valid |
Show only currently valid certificates |
Public Key Algorithm (--key-algo):
rsa → Any RSA variantrsa-pss, pss → RSA-PSS specificallyec, ecc → Any elliptic curveecdsa → ECDSA specificallyed25519, ed448, eddsa → EdDSA algorithmsdilithium, ml-dsa → Post-quantum Dilithium/ML-DSAkyber, ml-kem → Post-quantum Kyber/ML-KEMsm2 → Chinese SM2gost → Russian GOSTSignature Algorithm (--sig-algo):
sha → Any SHA-based signaturesha1, sha-1 → SHA-1 specificallysha2 → SHA-256, SHA-384, or SHA-512sha256, sha-256 → SHA-256 specificallyrsa → Any RSA signatureecdsa → ECDSA signaturesmd5 → MD5 signatures (deprecated)Multiple Values (OR): Same flag multiple times creates OR condition
# Find certificates from Apple OR Microsoft
cert-dump -R --org Apple --org Microsoft /path
Multiple Flags (AND): Different flags create AND condition
# Find Apple certificates with EC keys
cert-dump -R --org Apple --key-algo ec /path
Complex Filtering:
# Find certificates that are:
# - From Apple OR Google (OR)
# - Using EC keys (AND)
# - Currently valid (AND)
cert-dump -R --org Apple --org Google --key-algo ec --valid /path
Security Auditing:
# Find weak certificates with SHA-1
cert-dump -R --sig-algo sha1 /path
# Find small RSA keys
cert-dump -R --key-algo rsa --key-size 1024 /path
# Find expired certificates
cert-dump -R --expired --dump -o expired_certs /path
Certificate Inventory:
# Catalog by vendor
cert-dump -R --org Apple --sqlite apple.db /System/Library/Keychains
cert-dump -R --org DigiCert --sqlite digicert.db /System/Library/Keychains
# Catalog by algorithm
cert-dump -R --key-algo ec --json /path > ec_certs.jsonl
Combined with Other Features:
# Extract filtered certificates
cert-dump -R --org Apple --key-algo ec --dump -o apple_ec /path
# Filter and visualize in tree format
cert-dump -R --org "Let's Encrypt" --tree /path
# Filter and export to JSON
cert-dump -R --expired --json /path | jq 'select(.public_key_bits < 2048)'
# Use verbose mode to see filtering statistics
cert-dump -R --org Apple -v /path
# Output: Filtered out 250 certificate(s) that didn't match criteria
Migration Planning:
# Find legacy algorithm usage
cert-dump -R --sig-algo md5 /path
cert-dump -R --sig-algo sha1 /path
# Find modern certificates (SHA-256 with strong keys)
cert-dump -R --sig-algo sha256 --key-size 2048 --key-size 4096 /path
For complete filtering documentation with all algorithm variants and advanced examples, see FILTERING.md.
The --tree flag displays certificates in a hierarchical tree format, showing parent-child signing relationships. This helps visualize certificate chains and understand trust relationships within PKI hierarchies.
The tree view automatically:
# Display all certificates in tree format
cert-dump --recursive /path/to/certs --tree
# Single file with certificate chain
cert-dump cert-chain.pem --tree
# Analyze system certificate stores
cert-dump -R --tree /System/Library/Keychains/
The tree displays:
[ROOT/Self-Signed] for self-signed certificatesExample Output:
Certificate Relationship Tree
================================================================================
Certificate #0 CN=Root CA, O=Example Corp, C=US [ROOT/Self-Signed]
Serial: 0E068A98C23823B2F51C1734E83B156D1F4E9401
└─ Certificate #2 CN=Intermediate CA, O=Example Corp, C=US
Serial: 1095E96F97590B45E75F3276DFB31B933D90BAA1
Issued by: CN=Root CA, O=Example Corp, C=US
└─ Certificate #1 CN=example.com, O=Example Corp, C=US
Serial: 0E3D9F6C511979EB0F88418DB048905F5D39B560
Issued by: CN=Intermediate CA, O=Example Corp, C=US
Tree view works seamlessly with all filtering options:
# Show only RSA certificates and their relationships
cert-dump -R --tree --key-algo rsa /path/to/certs
# Visualize only valid certificates from a specific organization
cert-dump -R --tree --valid --org "Let's Encrypt" /path
# Show expired certificate chains
cert-dump -R --tree --expired /path
# Find and visualize specific certificate types
cert-dump -R --tree --key-algo ec --key-size 384 /path
Analyzing System Certificate Stores:
# macOS system roots
cert-dump -R --tree /System/Library/Keychains/
# Linux system CA bundle
cert-dump --tree /etc/ssl/certs/ca-certificates.crt
Verifying Certificate Chains:
# Check if leaf certificate chains to expected root
cert-dump -R --tree ./certificate-bundle/
Auditing PKI Hierarchies:
# Find all certificates signed by a specific CA
cert-dump -R --tree --issuer "Intermediate CA" /pki/
Debugging TLS Issues:
# Visualize certificate relationships in TLS bundle
cert-dump --tree server-bundle.pem
Linking Logic:
Performance:
Limitations:
For complete tree visualization documentation including advanced scenarios and examples, see TREE.md.
cert-dump is optimized for speed:
memchr for fast pattern matching in large binariesTypical performance:
--threadsSingle-file mode:
Directory scanning mode:
-R flag is used, or any duplicate-detection flags are active--unique-only to see only first occurrences, or --mark-duplicates to annotate all occurrences--follow-symlinks to change this behaviorGeneral:
-v to see warningsMIT License
Copyright (c) 2025 Kenan Sulayman
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.