move install_crypto_provider to swarm-secret-client
The rustls provider install is process setup every swarm binary runs, and swarm-secret-client depends on no other swarm crate, so a binary that only needs the provider and the store no longer links the queue client. - swarm-secret-client/src/lib.rs, Cargo.toml: the function, its test, a `//!` line on why it lives there, and the rustls dependency; rustls `ring` as a dev-dependency feature, so the test builds both providers as the binaries do and fails if the install is dropped. - swarm-queue-client/src/lib.rs, Cargo.toml: function and test removed; `connect()` calls the secret client's; rustls dropped (no other use), swarm-secret-client added. - swarm-metrics-auth/Cargo.toml: drop swarm-queue-client, whose only use was the provider; the binary no longer links async-nats. - swarm-logs-auth, swarm-logs, swarm-metrics, swarm-ci-metrics Cargo.toml: the dep comment no longer names the provider (they keep the dep for agent_token / the OIDC mint). - Cargo.toml: the rustls comment names the provider's new home. - 14 call sites (hive-agent, hive-c0re, hive-subagent-mcp x2, swarm-builder, swarm-ci-metrics, swarm-claude-login, swarm-controller, swarm-logs-auth, swarm-logs, swarm-metrics-auth, swarm-metrics, swarm-nats-auth, swarm-review-classifier): one-line path change. - Cargo.lock: the dependency edges above.
This commit is contained in:
parent
d9c586ef94
commit
44984e0d36
25 changed files with 64 additions and 47 deletions
|
|
@ -941,18 +941,6 @@ pub fn max_payload(client: &async_nats::Client) -> usize {
|
|||
client.server_info().max_payload
|
||||
}
|
||||
|
||||
/// Install `aws-lc-rs` as the process-wide rustls crypto provider. Call it
|
||||
/// first thing in `main` of every binary that dials the queue.
|
||||
///
|
||||
/// rustls is built with both `ring` and `aws-lc-rs`; without an installed
|
||||
/// default, the first TLS handshake panics (async-nats builds its config with
|
||||
/// `ClientConfig::builder()`) and the client never connects. `aws-lc-rs`
|
||||
/// because it is what reqwest uses when nothing is installed.
|
||||
pub fn install_crypto_provider() {
|
||||
// `Err` only means a provider is already installed, which is all this needs.
|
||||
let _already_installed = rustls::crypto::aws_lc_rs::default_provider().install_default();
|
||||
}
|
||||
|
||||
/// Connect to the swarm queue, presenting a token on each connection attempt
|
||||
/// and minting a fresh one only when the cached one is near expiry. Reply
|
||||
/// inboxes are under [`client_inbox_prefix`] of `cfg.client_id`.
|
||||
|
|
@ -962,7 +950,7 @@ pub fn install_crypto_provider() {
|
|||
/// token expires, the controller keeps serving, its status data quietly stops
|
||||
/// updating, and nothing says so until someone reads a dashboard.
|
||||
pub async fn connect(cfg: QueueConfig) -> Result<async_nats::Client, Error> {
|
||||
install_crypto_provider();
|
||||
swarm_secret_client::install_crypto_provider();
|
||||
// Trusts `cfg.ca_file` when set (the swarm's own CA, when the token
|
||||
// endpoint is signed by it) — see `build_http_client`. A timeout too,
|
||||
// because this client runs INSIDE the auth callback: a token endpoint
|
||||
|
|
@ -1134,14 +1122,6 @@ mod tests {
|
|||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_tls_client_config_builds_once_the_provider_is_installed() {
|
||||
install_crypto_provider();
|
||||
let _config = rustls::ClientConfig::builder()
|
||||
.with_root_certificates(rustls::RootCertStore::empty())
|
||||
.with_no_client_auth();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn a_debug_print_of_a_config_does_not_carry_a_held_secret() {
|
||||
let cfg = QueueConfig {
|
||||
|
|
|
|||
Loading…
Reference in a new issue