rustls-pemfile

A basic parser for PEM-encoded keys and certificates in Rust

Library
Cargo
v2.2.0
73stars
Custom / Unknown

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
36/100Needs Attention
Development Activity0
Maintenance20
Community44
Maturity60
Momentum20

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
76/100Good
Architecture78
Code Quality82
Innovation60
Learning Curve85

rustls-pemfile is a small, focused Rust crate for parsing .pem files containing cryptographic material — certificates, private keys, certificate signing requests, and revocation lists. It reads the base64-armored PEM sections and hands back their raw DER encodings without attempting to decode the DER itself, leaving that to callers such as rustls or rustls-pki-types.

The crate is maintained under the rustls organization and is a common companion to rustls-based TLS setups, used to load server certificates and private keys from disk before constructing a TLS configuration. As of 2.2.0 its core logic has been absorbed into rustls-pki-types, with this crate now acting as a stable, familiar API wrapper around that newer implementation.

What You Get

  • Streaming (read_one) and bulk (read_all) PEM section parsing from any io::BufRead
  • Convenience iterators for certificates, RSA/PKCS8/SEC1 private keys, CSRs, and CRLs
  • A read_one_from_slice API for no-std environments working on in-memory buffers
  • Zero unsafe code (#![forbid(unsafe_code)]) and no-std support via an opt-out std feature
  • Direct interoperability with rustls-pki-types DER wrapper types

Common Use Cases

  • Loading a server’s certificate chain and private key from disk to configure rustls
  • Extracting a CSR or CRL from a PEM bundle in a certificate-management tool
  • Parsing PEM content in embedded or no-std contexts where no file I/O is available
  • Migrating legacy PEM-parsing code onto the newer rustls-pki-types PEM APIs

Under The Hood

Architecture - The crate is intentionally tiny: pemfile.rs implements the core line-oriented PEM section reader (read_one, read_all, read_one_from_slice) that scans for -----BEGIN ... -----/-----END ... ----- markers, base64-decodes the body, and classifies the section into an Item enum (X509Certificate, Pkcs1Key, Pkcs8Key, Sec1Key, Crl, Csr, SubjectPublicKeyInfo). lib.rs is a thin convenience layer on top, exposing certs(), private_key(), csr(), crls(), and per-key-type iterators that filter the general read_one stream down to one item kind.

Tech Stack - The only runtime dependency is rustls-pki-types, which supplies the DER-wrapper newtypes (CertificateDer, PrivateKeyDer, etc.) that this crate’s functions return; base64 decoding and DER handling as of 2.2.0 are delegated to that crate’s PEM implementation rather than a local base64 dependency, shrinking the dependency tree. The crate is #![no_std] by default with an opt-in std feature gating anything that needs io::BufRead, and forbids unsafe code entirely.

Code Quality - Despite its small size (~540 lines including tests), the crate has a dedicated tests.rs module plus an integration test target and a criterion-style bencher benchmark, and enables strict lint gates (missing_docs, unused_qualifications, trivial_casts) at the crate root, meaning every public item must be documented. Error handling is expressed via a small Error enum surfaced through io::Error, rather than panics.

API Design - The public surface is deliberately narrow and example-driven: the crate-level doc comment shows the exact iter::from_fn(|| read_one(&mut reader).transpose()) pattern used throughout the ecosystem, and convenience functions like certs()/private_key() cover the 90% use case without requiring callers to match on the Item enum themselves. The main friction point is that the crate is now positioned as a legacy-compatible shim over rustls-pki-types’s newer PEM APIs, so new adopters are nudged toward migrating away eventually.

Used by 6 apps in this directory

Rust
86%
Other

Arroyo

Data Engineering · Analytics

5,005

A distributed stream processing engine written in Rust that lets you write SQL to run stateful, real-time computations over data streams with subsecond results.

View details
86
Repo Health
74
Technical
62
Dependency
Built with
Rust86%
Updated 1 weeks ago
TypeScript
91%
MIT

bunqueue

Developer Tools · Devops

535

High-performance job queue for Bun — SQLite persistence, cron scheduling, DLQ, S3 backups, and a native MCP server, all without Redis.

View details
74
Repo Health
83
Technical
76
Dependency
Built with
TypeScript91%
Updated 2 weeks ago
Rust
100%
Other

Meilisearch

Search

59,012

Lightning-fast hybrid search engine with AI-powered semantic and full-text retrieval for modern applications.

View details
90
Repo Health
88
Technical
68
Dependency
Built with
Rust100%
Updated 5 days ago
Go
80%
AGPL 3.0

PeerDB

Data Engineering · Databases

3,241

Postgres-native ETL that streams change data capture in real time to Snowflake, BigQuery, ClickHouse, S3, and Kafka — up to 10x faster than general-purpose pipelines, managed through a familiar Postgres SQL interface.

View details
88
Repo Health
76
Technical
68
Dependency
Built with
Go80%
TypeScript13%
Updated today
Rust
89%
Apache 2.0

Qdrant

Databases · AI Development · Search

34,058

Open-source vector database and search engine built in Rust for production-grade AI applications — from semantic search to RAG pipelines and recommendation systems.

View details
92
Repo Health
87
Technical
69
Dependency
Built with
Rust89%
Updated yesterday
Rust
98%

Stalwart

Collaboration

14,255

All-in-one secure mail and collaboration server covering IMAP, JMAP, SMTP, CalDAV, CardDAV, and WebDAV in a single memory-safe Rust binary.

View details
89
Repo Health
81
Technical
68
Dependency
Built with
Rust98%
Updated yesterday

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search