Skip to content

Commit 9930b06

Browse files
committed
fix: panic when there is no configured TLS provider #546
1 parent e62d9e5 commit 9930b06

4 files changed

Lines changed: 11 additions & 0 deletions

File tree

rust/Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/pact_ffi/src/lib.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,14 @@ pub unsafe extern "C" fn pactffi_init_with_log_level(level: *const c_char) {
123123
if let Err(err) = tracing::subscriber::set_global_default(subscriber) {
124124
eprintln!("Failed to initialise global tracing subscriber - {err}");
125125
};
126+
126127
init_plugin_log_sink();
128+
129+
if rustls::crypto::CryptoProvider::get_default().is_none() {
130+
if let Err(_) = rustls::crypto::ring::default_provider().install_default() {
131+
warn!("failed to installed the default crypto provider");
132+
}
133+
}
127134
}
128135

129136
/// Enable ANSI coloured output on Windows. On non-Windows platforms, this function is a no-op.

rust/pact_matching/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ uuid = { version = "1.24.0", features = ["v4"] }
6060
onig = { version = "6.5.1", default-features = false }
6161
pact-plugin-driver = { version = "~1.2.3", optional = true, default-features = false }
6262
reqwest = { version = "0.13.4", default-features = false, features = ["rustls-no-provider", "json"] }
63+
rustls = { version = "0.23.43", default-features = false }
6364
tokio = { version = "1.49.0", features = ["full"] }
6465

6566
[target.'cfg(target_family = "wasm")'.dependencies]

rust/pact_matching/src/metrics.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,8 @@ pub fn send_metrics(event: MetricEvent) {
159159
pub async fn send_metrics_async(event: MetricEvent) {
160160
if do_not_track() {
161161
debug!("'PACT_DO_NOT_TRACK' environment variable is set, will not send metrics");
162+
} else if rustls::crypto::CryptoProvider::get_default().is_none() {
163+
debug!("No TLS provider, will not send metrics");
162164
} else {
163165
log_warning();
164166
let ci_context = if CIS.iter()

0 commit comments

Comments
 (0)