Compare commits
1 Commits
master
...
fix/15-rat
| Author | SHA1 | Date | |
|---|---|---|---|
| e00c5244e7 |
@ -181,7 +181,7 @@ tls:
|
|||||||
ca_cert: "/etc/linux_patch_api/certs/ca.pem"
|
ca_cert: "/etc/linux_patch_api/certs/ca.pem"
|
||||||
server_cert: "/etc/linux_patch_api/certs/server.pem"
|
server_cert: "/etc/linux_patch_api/certs/server.pem"
|
||||||
server_key: "/etc/linux_patch_api/certs/server.key"
|
server_key: "/etc/linux_patch_api/certs/server.key"
|
||||||
# TLS 1.3 is the only supported version (hardcoded, not configurable)
|
min_tls_version: "1.3"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
max_concurrent: 5
|
max_concurrent: 5
|
||||||
|
|||||||
@ -395,7 +395,7 @@ tls:
|
|||||||
ca_cert: "/etc/linux_patch_api/certs/ca.pem"
|
ca_cert: "/etc/linux_patch_api/certs/ca.pem"
|
||||||
server_cert: "/etc/linux_patch_api/certs/server.pem"
|
server_cert: "/etc/linux_patch_api/certs/server.pem"
|
||||||
server_key: "/etc/linux_patch_api/certs/server.key"
|
server_key: "/etc/linux_patch_api/certs/server.key"
|
||||||
# TLS 1.3 is the only supported version (hardcoded, not configurable)
|
min_tls_version: "1.3"
|
||||||
|
|
||||||
# Job Configuration
|
# Job Configuration
|
||||||
jobs:
|
jobs:
|
||||||
|
|||||||
@ -14,7 +14,7 @@ tls:
|
|||||||
ca_cert: "/etc/linux_patch_api/certs/ca.pem"
|
ca_cert: "/etc/linux_patch_api/certs/ca.pem"
|
||||||
server_cert: "/etc/linux_patch_api/certs/server.pem"
|
server_cert: "/etc/linux_patch_api/certs/server.pem"
|
||||||
server_key: "/etc/linux_patch_api/certs/server.key"
|
server_key: "/etc/linux_patch_api/certs/server.key"
|
||||||
# TLS 1.3 is the only supported version (hardcoded, not configurable)
|
min_tls_version: "1.3"
|
||||||
|
|
||||||
# Job Configuration
|
# Job Configuration
|
||||||
jobs:
|
jobs:
|
||||||
|
|||||||
@ -143,14 +143,12 @@ impl ClientCertVerifier for CrlAwareVerifier {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// mTLS Configuration
|
/// mTLS Configuration
|
||||||
///
|
|
||||||
/// TLS 1.3 is the only supported protocol version — this is hardcoded
|
|
||||||
/// in `build_rustls_config()` and cannot be configured via this struct.
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct MtlsConfig {
|
pub struct MtlsConfig {
|
||||||
pub ca_cert_path: String,
|
pub ca_cert_path: String,
|
||||||
pub server_cert_path: String,
|
pub server_cert_path: String,
|
||||||
pub server_key_path: String,
|
pub server_key_path: String,
|
||||||
|
pub min_tls_version: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Build a rustls ServerConfig with client certificate verification.
|
/// Build a rustls ServerConfig with client certificate verification.
|
||||||
|
|||||||
@ -33,6 +33,8 @@ pub struct TlsConfig {
|
|||||||
pub ca_cert: String,
|
pub ca_cert: String,
|
||||||
pub server_cert: String,
|
pub server_cert: String,
|
||||||
pub server_key: String,
|
pub server_key: String,
|
||||||
|
#[serde(default = "default_tls_version")]
|
||||||
|
pub min_tls_version: String,
|
||||||
/// Path to persist the CRL fetched from the manager.
|
/// Path to persist the CRL fetched from the manager.
|
||||||
/// Defaults to /etc/linux_patch_api/certs/crl.pem
|
/// Defaults to /etc/linux_patch_api/certs/crl.pem
|
||||||
#[serde(default = "default_crl_path")]
|
#[serde(default = "default_crl_path")]
|
||||||
@ -47,6 +49,10 @@ fn default_true() -> bool {
|
|||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn default_tls_version() -> String {
|
||||||
|
"1.3".to_string()
|
||||||
|
}
|
||||||
|
|
||||||
/// Jobs configuration
|
/// Jobs configuration
|
||||||
#[derive(Debug, Deserialize, Serialize, Clone)]
|
#[derive(Debug, Deserialize, Serialize, Clone)]
|
||||||
pub struct JobsConfig {
|
pub struct JobsConfig {
|
||||||
@ -495,19 +501,6 @@ impl AppConfig {
|
|||||||
let content = std::fs::read_to_string(path)
|
let content = std::fs::read_to_string(path)
|
||||||
.with_context(|| format!("Failed to read config file: {}", path))?;
|
.with_context(|| format!("Failed to read config file: {}", path))?;
|
||||||
|
|
||||||
// Check for deprecated fields before typed parsing
|
|
||||||
if let Ok(value) = serde_yaml::from_str::<serde_yaml::Value>(&content) {
|
|
||||||
if let Some(tls) = value.get("tls") {
|
|
||||||
if tls.get("min_tls_version").is_some() {
|
|
||||||
tracing::warn!(
|
|
||||||
"Config contains deprecated 'tls.min_tls_version' field. \
|
|
||||||
This field is ignored — TLS 1.3 is the only supported version. \
|
|
||||||
Remove it from your config to silence this warning."
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let config: AppConfig = serde_yaml::from_str(&content)
|
let config: AppConfig = serde_yaml::from_str(&content)
|
||||||
.with_context(|| format!("Failed to parse config file: {}", path))?;
|
.with_context(|| format!("Failed to parse config file: {}", path))?;
|
||||||
|
|
||||||
|
|||||||
@ -8,5 +8,4 @@
|
|||||||
pub mod loader;
|
pub mod loader;
|
||||||
pub use loader::{validate_certs, AppConfig, CertStatus, EnrollmentConfig, RateLimitConfig};
|
pub use loader::{validate_certs, AppConfig, CertStatus, EnrollmentConfig, RateLimitConfig};
|
||||||
pub mod validator;
|
pub mod validator;
|
||||||
pub use validator::validate_config_warnings;
|
|
||||||
pub mod watcher;
|
pub mod watcher;
|
||||||
|
|||||||
@ -1,25 +1,3 @@
|
|||||||
//! Configuration Validator
|
//! Configuration Validator
|
||||||
//!
|
//!
|
||||||
//! Validates configuration values and warns about deprecated fields.
|
//! Placeholder - implementation in future phases
|
||||||
|
|
||||||
use tracing::warn;
|
|
||||||
|
|
||||||
/// Validate configuration for deprecated or unknown fields.
|
|
||||||
///
|
|
||||||
/// This is called after config loading to emit warnings for fields
|
|
||||||
/// that are no longer functional but may still be present in operator
|
|
||||||
/// config files.
|
|
||||||
pub fn validate_config_warnings(config_yaml: &str) {
|
|
||||||
// Check for deprecated tls.min_tls_version field
|
|
||||||
if let Ok(value) = serde_yaml::from_str::<serde_yaml::Value>(config_yaml) {
|
|
||||||
if let Some(tls) = value.get("tls") {
|
|
||||||
if tls.get("min_tls_version").is_some() {
|
|
||||||
warn!(
|
|
||||||
"Config contains deprecated 'tls.min_tls_version' field. \
|
|
||||||
This field is ignored — TLS 1.3 is the only supported version. \
|
|
||||||
Remove it from your config to silence this warning."
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@ -368,15 +368,16 @@ async fn main() -> Result<()> {
|
|||||||
ca_cert = %tls_config.ca_cert,
|
ca_cert = %tls_config.ca_cert,
|
||||||
server_cert = %tls_config.server_cert,
|
server_cert = %tls_config.server_cert,
|
||||||
server_key = %tls_config.server_key,
|
server_key = %tls_config.server_key,
|
||||||
|
min_tls_version = %tls_config.min_tls_version,
|
||||||
crl_path = %tls_config.crl_path,
|
crl_path = %tls_config.crl_path,
|
||||||
"Initializing mTLS authentication with TLS 1.3 binding"
|
"Initializing mTLS authentication with TLS binding"
|
||||||
);
|
);
|
||||||
|
|
||||||
// TLS 1.3 is the only supported version — hardcoded in build_rustls_config()
|
|
||||||
let mtls_config = mtls::MtlsConfig {
|
let mtls_config = mtls::MtlsConfig {
|
||||||
ca_cert_path: tls_config.ca_cert.clone(),
|
ca_cert_path: tls_config.ca_cert.clone(),
|
||||||
server_cert_path: tls_config.server_cert.clone(),
|
server_cert_path: tls_config.server_cert.clone(),
|
||||||
server_key_path: tls_config.server_key.clone(),
|
server_key_path: tls_config.server_key.clone(),
|
||||||
|
min_tls_version: tls_config.min_tls_version.clone(),
|
||||||
};
|
};
|
||||||
|
|
||||||
// Load CRL from disk into the shared CRL state
|
// Load CRL from disk into the shared CRL state
|
||||||
|
|||||||
@ -77,6 +77,7 @@ fn build_tls_config(cert_dir: &std::path::Path) -> TlsConfig {
|
|||||||
.join("server.key.pem")
|
.join("server.key.pem")
|
||||||
.to_string_lossy()
|
.to_string_lossy()
|
||||||
.to_string(),
|
.to_string(),
|
||||||
|
min_tls_version: "1.3".to_string(),
|
||||||
crl_path: String::new(), // No CRL in E2E tests
|
crl_path: String::new(), // No CRL in E2E tests
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,6 +15,7 @@ mod mtls_tests {
|
|||||||
ca_cert_path: "/etc/linux_patch_api/certs/ca.pem".to_string(),
|
ca_cert_path: "/etc/linux_patch_api/certs/ca.pem".to_string(),
|
||||||
server_cert_path: "/etc/linux_patch_api/certs/server.pem".to_string(),
|
server_cert_path: "/etc/linux_patch_api/certs/server.pem".to_string(),
|
||||||
server_key_path: "/etc/linux_patch_api/certs/server.key".to_string(),
|
server_key_path: "/etc/linux_patch_api/certs/server.key".to_string(),
|
||||||
|
min_tls_version: "1.3".to_string(),
|
||||||
};
|
};
|
||||||
|
|
||||||
assert_eq!(config.ca_cert_path, "/etc/linux_patch_api/certs/ca.pem");
|
assert_eq!(config.ca_cert_path, "/etc/linux_patch_api/certs/ca.pem");
|
||||||
@ -26,6 +27,7 @@ mod mtls_tests {
|
|||||||
config.server_key_path,
|
config.server_key_path,
|
||||||
"/etc/linux_patch_api/certs/server.key"
|
"/etc/linux_patch_api/certs/server.key"
|
||||||
);
|
);
|
||||||
|
assert_eq!(config.min_tls_version, "1.3");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|||||||
Reference in New Issue
Block a user