Expand description
Validation utilities for TLS certificates, domains, and configuration.
§Security
This module provides comprehensive validation for:
- Certificate file paths and accessibility - Validates PEM format, path traversal detection
- Domain names (RFC 1035 compliance) - Prevents invalid domain configurations
- Configuration safety - Ensures TLS configuration is safe before use
§Path Traversal Protection
The module detects and rejects paths containing:
..(directory traversal)~(home directory expansion attacks)
This prevents configuration-based path traversal attacks.
§Domain Validation
Domains must comply with RFC 1035:
- Max 253 characters total
- Each label max 63 characters
- Labels contain only alphanumerics and hyphens
- Labels cannot start or end with hyphen
- Supports wildcard domains (
*.example.com)
§Examples
use synapse_pingora::validation::{validate_domain_name, validate_certificate_file};
// Validate a domain
assert!(validate_domain_name("example.com").is_ok());
assert!(validate_domain_name("*.example.com").is_ok());
assert!(validate_domain_name("-invalid.com").is_err()); // Invalid format
// Validate a certificate file
assert!(validate_certificate_file("/etc/certs/server.crt").is_ok());
assert!(validate_certificate_file("/etc/certs/invalid.txt").is_err()); // Not PEM formatStructs§
- Ssrf
Error - SSRF protection error.
Enums§
- Validation
Error - Validation errors that can occur during configuration validation.
Functions§
- validate_
certificate_ file - Validates a certificate file is in PEM format and contains cert data.
- validate_
cidr - Validates a CIDR block string.
- validate_
domain_ name - Validates a domain name according to RFC 1035.
- validate_
file_ path - Validates a file path exists and is readable.
- validate_
hostname - Validates a hostname (alias for domain validation).
- validate_
private_ key_ file - Validates a private key file is in PEM format and meets minimum security requirements.
- validate_
rate_ limit - Validates rate limit configuration.
- validate_
tls_ config - Validates a complete TLS configuration.
- validate_
upstream - Validates an upstream address (host:port) with SSRF protection.
- validate_
waf_ threshold - Validates WAF risk threshold (0-100).
Type Aliases§
- Validation
Result - Result type for validation operations.