Skip to content

Commit fc17fba

Browse files
authored
fix(deps): load default and legacy openssl providers (vectordotdev#18276)
* fix(deps): load default and legacy openssl providers * hard error
1 parent 4ec6c11 commit fc17fba

File tree

2 files changed

+34
-22
lines changed

2 files changed

+34
-22
lines changed

src/app.rs

+25-21
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ pub struct Application {
6262
pub require_healthy: Option<bool>,
6363
pub config: ApplicationConfig,
6464
pub signals: SignalPair,
65-
pub openssl_legacy_provider: Option<Provider>,
65+
pub openssl_providers: Option<Vec<Provider>>,
6666
}
6767

6868
impl ApplicationConfig {
@@ -196,11 +196,11 @@ impl Application {
196196
debug!(message = "Disabled probing and configuration of root certificate locations on the system for OpenSSL.");
197197
}
198198

199-
let openssl_legacy_provider = opts
199+
let openssl_providers = opts
200200
.root
201201
.openssl_legacy_provider
202-
.then(load_openssl_legacy_provider)
203-
.flatten();
202+
.then(load_openssl_legacy_providers)
203+
.transpose()?;
204204

205205
let runtime = build_runtime(opts.root.threads, "vector-worker")?;
206206

@@ -222,7 +222,7 @@ impl Application {
222222
require_healthy: opts.root.require_healthy,
223223
config,
224224
signals,
225-
openssl_legacy_provider,
225+
openssl_providers,
226226
},
227227
))
228228
}
@@ -239,7 +239,7 @@ impl Application {
239239
require_healthy,
240240
config,
241241
signals,
242-
openssl_legacy_provider,
242+
openssl_providers,
243243
} = self;
244244

245245
let topology_controller = SharedTopologyController::new(TopologyController {
@@ -257,7 +257,7 @@ impl Application {
257257
graceful_crash_receiver: config.graceful_crash_receiver,
258258
signals,
259259
topology_controller,
260-
openssl_legacy_provider,
260+
openssl_providers,
261261
})
262262
}
263263
}
@@ -267,7 +267,7 @@ pub struct StartedApplication {
267267
pub graceful_crash_receiver: mpsc::UnboundedReceiver<ShutdownError>,
268268
pub signals: SignalPair,
269269
pub topology_controller: SharedTopologyController,
270-
pub openssl_legacy_provider: Option<Provider>,
270+
pub openssl_providers: Option<Vec<Provider>>,
271271
}
272272

273273
impl StartedApplication {
@@ -281,7 +281,7 @@ impl StartedApplication {
281281
graceful_crash_receiver,
282282
signals,
283283
topology_controller,
284-
openssl_legacy_provider,
284+
openssl_providers,
285285
} = self;
286286

287287
let mut graceful_crash = UnboundedReceiverStream::new(graceful_crash_receiver);
@@ -313,7 +313,7 @@ impl StartedApplication {
313313
signal,
314314
signal_rx,
315315
topology_controller,
316-
openssl_legacy_provider,
316+
openssl_providers,
317317
}
318318
}
319319
}
@@ -368,7 +368,7 @@ pub struct FinishedApplication {
368368
pub signal: SignalTo,
369369
pub signal_rx: SignalRx,
370370
pub topology_controller: SharedTopologyController,
371-
pub openssl_legacy_provider: Option<Provider>,
371+
pub openssl_providers: Option<Vec<Provider>>,
372372
}
373373

374374
impl FinishedApplication {
@@ -377,7 +377,7 @@ impl FinishedApplication {
377377
signal,
378378
signal_rx,
379379
topology_controller,
380-
openssl_legacy_provider,
380+
openssl_providers,
381381
} = self;
382382

383383
// At this point, we'll have the only reference to the shared topology controller and can
@@ -392,7 +392,7 @@ impl FinishedApplication {
392392
SignalTo::Quit => Self::quit(),
393393
_ => unreachable!(),
394394
};
395-
drop(openssl_legacy_provider);
395+
drop(openssl_providers);
396396
status
397397
}
398398

@@ -571,13 +571,17 @@ pub fn init_logging(color: bool, format: LogFormat, log_level: &str, rate: u64)
571571
///
572572
/// The returned [Provider] must stay in scope for the entire lifetime of the application, as it
573573
/// will be unloaded when it is dropped.
574-
pub fn load_openssl_legacy_provider() -> Option<Provider> {
574+
pub fn load_openssl_legacy_providers() -> Result<Vec<Provider>, ExitCode> {
575575
warn!(message = "DEPRECATED The openssl legacy provider provides algorithms and key sizes no longer recommended for use.");
576-
Provider::try_load(None, "legacy", true)
577-
.map(|provider| {
578-
info!(message = "Loaded openssl legacy provider.");
579-
provider
580-
})
581-
.map_err(|error| error!(message = "Failed to load openssl legacy provider.", %error))
582-
.ok()
576+
["legacy", "default"].into_iter().map(|provider_name| {
577+
Provider::try_load(None, provider_name, true)
578+
.map(|provider| {
579+
info!(message = "Loaded openssl provider.", provider = provider_name);
580+
provider
581+
})
582+
.map_err(|error| {
583+
error!(message = "Failed to load openssl provider.", provider = provider_name, %error);
584+
exitcode::UNAVAILABLE
585+
})
586+
}).collect()
583587
}

src/cli.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,15 @@ pub struct RootOpts {
196196
pub allocation_tracing_reporting_interval_ms: u64,
197197

198198
/// Load the OpenSSL legacy provider.
199-
#[arg(long, env = "VECTOR_OPENSSL_LEGACY_PROVIDER", default_value = "true")]
199+
#[arg(
200+
long,
201+
env = "VECTOR_OPENSSL_LEGACY_PROVIDER",
202+
default_value = "true",
203+
default_missing_value = "true",
204+
num_args = 0..=1,
205+
require_equals = true,
206+
action = ArgAction::Set
207+
)]
200208
pub openssl_legacy_provider: bool,
201209

202210
/// Disable probing and configuration of root certificate locations on the system for OpenSSL.

0 commit comments

Comments
 (0)