secure_network
TLS configuration validation, SPKI certificate pinning, mTLS identity, and cleartext detection for OWASP MASVS-NETWORK-1 and MASVS-NETWORK-2. Part of the SunLit Security Libraries workspace.
When to reach for this crate
- You're shipping a mobile or desktop app and need to pin server certificates by SPKI hash, with current+backup pin rotation.
- You operate an mTLS gateway and need to extract and revocation-check client identities from a verified chain.
- You need to validate TLS configuration (allowed versions, cipher suites) against a policy without performing the handshake yourself.
- You need a cleartext detector to guarantee mobile traffic isn't slipping out over plain HTTP.
All types are pure-Rust policy objects and validators — they do not perform TLS handshakes. The application provides raw certificate chains and TLS parameters; this crate provides the validation logic.
Install
[]
= "0.1"
Quick examples
Certificate pinning by SPKI SHA-256
use ;
// Current pin and backup pin (best practice: always have a backup).
let pins = from_hex_hashes?;
let validator = new;
// Pass each presented leaf certificate (DER bytes) into validator.validate()
// during connection setup; reject the connection on mismatch.
# Ok::
TLS configuration policy
use ;
let policy = builder
.min_version
.allow_cipher
.allow_cipher
.build;
let result = policy.validate;
assert!;
Cleartext-traffic detection
use ;
let detector = default;
match detector.evaluate
What's inside
| Module | Use it for |
|---|---|
cert_pin::PinSet / CertPinValidator |
SPKI SHA-256 pin validation with multi-pin rotation. |
tls_policy::TlsPolicy |
Allowed-version and allowed-cipher policy for connection setup. |
tls_policy::TlsValidationResult / TlsDenyReason |
Structured validation results for logging/telemetry. |
cleartext::CleartextDetector |
Detect cleartext URLs/hosts for mobile/desktop egress checks. |
mtls::MtlsClientIdentity / MtlsClientIdentityStatus |
Typed mTLS client identity extraction from a verified chain. |
mtls::MtlsRevocationLookup / NoMtlsRevocations |
Pluggable revocation hooks (CRL, OCSP, custom store). |
error::NetworkSecurityError |
Structured errors with no PII or hostnames. |
Compatibility
- MSRV: 1.78
#![forbid(unsafe_code)],#![deny(missing_docs)]- Pure Rust; depends on
x509-parserandsha2
Status
Alpha.
Related crates
Part of the SunLit Security Libraries workspace:
| Crate | Purpose |
|---|---|
security_core |
Shared types, identity, classification, severity, redaction. |
security_events |
Security logging and tamper-evident audit chain. |
secure_errors |
Three-layer error model with redaction-safe public errors. |
secure_output |
Context-aware output encoders (HTML, JSON, URL, JS, CSS, XML, LDAP, shell). |
secure_data |
Secrets, envelope encryption, Argon2id, FIPS, mobile storage. |
secure_device_trust |
Native-client device trust and session certificates. |
secure_resilience |
RASP and environment-detection policy. |
secure_privacy |
PII classification, consent, retention, pseudonymization. |
secure_boundary |
Input validation, security headers, boundary protections. |
secure_identity |
JWT/OIDC, MFA, sessions, biometric step-up. |
secure_authz |
Typed deny-by-default authorization with device-trust predicates. |
Getting help
- Questions, ideas, design discussions — open a GitHub Discussion.
- Bug reports — use the bug-report template in GitHub Issues.
- Security issues — please do not open a public issue. See SECURITY.md for the responsible-disclosure process.
Contributing
Contributions are welcome. Please read CONTRIBUTING.md and the Code of Conduct before opening a PR.
License
Dual-licensed under MIT or Apache-2.0 at your option.