warp-openssl
Copilot instructions0 starsChanged 6 months agoMITView on GitHub
warp-openssl is a Rust crate that adds OpenSSL-based TLS support to warp (which dropped built-in TLS in v0.4). It provides a drop-in serve() function that replaces warp's, with a builder API for configuring certificates, client authentication, and TLS levels. Tests require the certificates in certs/ to be generated first. CI does this automatically. The crate is structured as a layered TLS server pipeline: Follow the Rust API Guidelines and these practices:
Where files are headingNew Copilot instructions files have more rules about branches and pull requests, and fewer about code style.
Of the Copilot instructions files we read, the 2,336 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
The file
Show its rules and text
We split this copilot-instructions.md into the rules it gives an agent
19 rules. About 0 are common, 2 are distinctive, and 17 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
17
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 51
Follow the Rust API Guidelines and these practices:
- Very specific: line 55
Run cargo fmt before committing — all code must conform to the default rustfmt style.
- Very specific: line 56
Run cargo clippy -- -D warnings and fix all warnings.
- Very specific: line 57
Prefer #[allow(clippy::...)] with a justification comment over blanket suppression if a lint must be silenced.
- Very specific: line 61
Use Result<T, E> for fallible operations.
- Very specific: line 63
Prefer ? operator for error propagation over explicit match on Result.
- Very specific: line 65
Use thiserror for library error enums or manual impl as done in this crate's TlsConfigError.
- Very specific: line 69
Avoid unsafe unless absolutely necessary (e.g., FFI boundaries with OpenSSL).
- Very specific: line 70
Every unsafe block must have a // SAFETY: comment explaining why the invariants are upheld.
- Very specific: line 75
Use the builder pattern with consuming self methods for configuration structs (as this crate does with OpensslServer).
- Very specific: line 78
Use #[must_use] on types/functions where ignoring the return value is likely a bug.
- Very specific: line 83
Use tokio as the async runtime (this crate's standard).
- Very specific: line 84
Prefer tokio::select! for multiplexing futures.
- Very specific: line 85
Avoid holding Mutex guards across .await points — use tokio::sync::Mutex if a lock must span awaits.
- Very specific: line 86
Ensure types are Send + Sync when used across task boundaries.
- Very specific: line 90
All public items must have doc comments (///) — enforced by #![deny(missing_docs)].
- Very specific: line 92
Use # Errors, # Panics, and # Safety sections in doc comments where applicable.
- Distinctive: line 97
Keep the dependency tree minimal.
- Very specific: line 99
Use feature flags to keep optional functionality behind gates (e.g., openssl-vendored).
≈ “Common” is an estimate: at least 1 in 5 of the 3,779 Copilot instructions files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Copilot Instructions for warp-openssl
Overview
warp-openssl is a Rust crate that adds OpenSSL-based TLS support to warp (which dropped built-in TLS in v0.4). It provides a drop-in serve() function that replaces warp's, with a builder API for configuring certificates, client authentication, and TLS levels.
Build & Test
# Generate test certificates (required before first build/test)
cd certs && ./gencerts.sh
# Build
cargo build
# Build with vendored OpenSSL (no system OpenSSL required)
cargo build --features openssl-vendored
# Run all tests
cargo test
# Run a specific test case
cargo test client_auth_required_client_valid_successTests require the certificates in certs/ to be generated first. CI does this automatically.
Architecture
The crate is structured as a layered TLS server pipeline:
server.rs— Public API.serve()creates anOpensslServer<F>builder. The builder configures TLS viaTlsConfigBuilderand binds to an address, spawning a tokio task that accepts connections throughAddrIncoming→TlsStream→ hyperauto::Builder.config.rs—TlsConfigBuilderassembles the OpenSSLSslAcceptorfrom cert/key/client-auth settings. Supports Mozilla TLS security levels (default:MozillaIntermediateV5), CRL lookups, andSSLKEYLOGFILEfor Wireshark debugging.stream.rs—TlsStreamwrapstokio_openssl::SslStreamand implementshyper::rt::Read/Write. Handles a two-phase state machine:Handshaking→Streaming, running theCertificateVerifiercallback after handshake completion.certificate.rs—Certificatetype extracts CN/OU/L from the peer X509. TheCertificateVerifiertrait is the extension point for custom client cert validation.acceptor.rs— ThinSslConfigstruct holding the builtSslAcceptorand optional verifier.
Key Conventions
- Builder pattern —
OpensslServeruses a consuming builder (selfnot&mut self), chaining throughwith_tls()which destructures and reconstructs the struct. - Client certificates via warp extensions — Peer certificates are injected into hyper request extensions, accessible in warp filters via
warp::filters::ext::optional::<Certificate>(). - Graceful shutdown — Uses
tokio_util::CancellationTokenpropagated to both the accept loop and individual connections. - Test certificates — Integration tests use
include_bytes!to embed certs fromcerts/. The test cert hierarchy is: CA → intermediate → localhost/client. - rstest parametrized tests — Tests use
rstestwith#[case]attributes to cover the matrix of auth modes (off/optional/required) × verifier results (valid/invalid) × client cert presence. - Lint attributes — The crate enforces
#![deny(missing_docs)]and#![deny(missing_debug_implementations)]— all public items must have doc comments andDebugimpls. - Error type — Uses a boxed error alias:
type Error = Box<dyn std::error::Error + Send + Sync + 'static>. - Deprecated API migration —
common_name()andorganizational_unit()are deprecated in favor of their plural forms (common_names(),organizational_units()).
Rust Coding Standards
Follow the Rust API Guidelines and these practices:
Formatting & Linting
- Run
cargo fmtbefore committing — all code must conform to the defaultrustfmtstyle. - Run
cargo clippy -- -D warningsand fix all warnings. Treat clippy lints as errors. - Prefer
#[allow(clippy::...)]with a justification comment over blanket suppression if a lint must be silenced.
Error Handling
- Use
Result<T, E>for fallible operations; neverpanic!orunwrap()in library code. unwrap()andexpect()are acceptable only in tests and examples.- Prefer
?operator for error propagation over explicitmatchonResult. - Error types should implement
std::error::Error,Display, andDebug. - Use
thiserrorfor library error enums or manualimplas done in this crate'sTlsConfigError.
Safety & Unsafe
- Avoid
unsafeunless absolutely necessary (e.g., FFI boundaries with OpenSSL). - Every
unsafeblock must have a// SAFETY:comment explaining why the invariants are upheld. - Minimize the scope of
unsafeblocks — extract safe wrappers.
API Design
- Use the builder pattern with consuming
selfmethods for configuration structs (as this crate does withOpensslServer). - Accept generic inputs: prefer
impl AsRef<[u8]>orimpl Into<T>over concrete types in public APIs. - Implement common traits eagerly on public types:
Debug,Clone,Send,Syncwhere applicable. - Use
#[must_use]on types/functions where ignoring the return value is likely a bug. - Mark types
#[non_exhaustive]if they may gain variants/fields in future versions.
Async & Concurrency
- Use
tokioas the async runtime (this crate's standard). - Prefer
tokio::select!for multiplexing futures; useCancellationTokenfor shutdown signaling. - Avoid holding
Mutexguards across.awaitpoints — usetokio::sync::Mutexif a lock must span awaits. - Ensure types are
Send + Syncwhen used across task boundaries.
Documentation
- All public items must have doc comments (
///) — enforced by#![deny(missing_docs)]. - Include usage examples in doc comments for public functions and types.
- Use
# Errors,# Panics, and# Safetysections in doc comments where applicable. - Link to relevant external docs (e.g., OpenSSL, warp) with
[text](url)in doc comments.
Dependencies
- Keep the dependency tree minimal. Justify each new dependency.
- Pin major versions in
Cargo.toml(e.g.,"0.10"not"*"). - Use feature flags to keep optional functionality behind gates (e.g.,
openssl-vendored).
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

