Skip to content

Commit 084b772

Browse files
committed
fix(envoy-client): add tls
1 parent 56f7599 commit 084b772

File tree

7 files changed

+72
-18
lines changed

7 files changed

+72
-18
lines changed

Cargo.lock

Lines changed: 55 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,6 @@ members = [
135135
tokio-cron-scheduler = "0.13.0"
136136
tokio-native-tls = "0.3.1"
137137
tokio-stream = "0.1.15"
138-
tokio-tungstenite = "0.26.0"
139138
tokio-util = "0.7"
140139
tower = "0.5"
141140
tracing = "0.1.40"
@@ -177,6 +176,10 @@ members = [
177176
[workspace.dependencies.pest]
178177
version = "2.7"
179178

179+
[workspace.dependencies.tokio-tungstenite]
180+
version = "0.26.0"
181+
features = ["rustls-tls-native-roots"]
182+
180183
[workspace.dependencies.rocksdb]
181184
version = "0.24"
182185
features = [ "multi-threaded-cf" ]
@@ -490,9 +493,6 @@ members = [
490493
package = "rivet-util"
491494
path = "engine/packages/util"
492495

493-
[workspace.dependencies.rivet-util-serde]
494-
path = "engine/packages/util-serde"
495-
496496
[workspace.dependencies.rivet-util-id]
497497
path = "engine/packages/util-id"
498498

engine/packages/guard/src/routing/pegboard_gateway/resolve_actor_query.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -221,9 +221,7 @@ fn serialize_actor_key(key: &[String]) -> Result<String> {
221221
continue;
222222
}
223223

224-
let escaped = part
225-
.replace('\\', "\\\\")
226-
.replace(KEY_SEPARATOR, "\\/");
224+
let escaped = part.replace('\\', "\\\\").replace(KEY_SEPARATOR, "\\/");
227225
escaped_parts.push(escaped);
228226
}
229227

engine/packages/pegboard-envoy/src/conn.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,8 @@ pub async fn handle_init(
264264
// Update the pool's protocol version. This is required for serverful pools because normally
265265
// the pool's protocol version is updated via the metadata_poller wf but that only runs for
266266
// serverless pools.
267-
tx.write(
267+
let ns_tx = tx.with_subspace(namespace::keys::subspace());
268+
ns_tx.write(
268269
&pegboard::keys::runner_config::ProtocolVersionKey::new(
269270
namespace_id,
270271
pool_name.clone(),

engine/packages/pegboard/src/keys/runner_config.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -244,18 +244,18 @@ impl TuplePack for ProtocolVersionKey {
244244
RUNNER,
245245
CONFIG,
246246
DATA,
247-
PROTOCOL_VERSION,
248247
self.namespace_id,
249248
&self.name,
249+
PROTOCOL_VERSION,
250250
);
251251
t.pack(w, tuple_depth)
252252
}
253253
}
254254

255255
impl<'de> TupleUnpack<'de> for ProtocolVersionKey {
256256
fn unpack(input: &[u8], tuple_depth: TupleDepth) -> PackResult<(&[u8], Self)> {
257-
let (input, (_, _, _, _, namespace_id, name)) =
258-
<(usize, usize, usize, usize, Id, String)>::unpack(input, tuple_depth)?;
257+
let (input, (_, _, _, namespace_id, name, _)) =
258+
<(usize, usize, usize, Id, String, usize)>::unpack(input, tuple_depth)?;
259259

260260
let v = ProtocolVersionKey { namespace_id, name };
261261

engine/sdks/rust/envoy-client/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ hex.workspace = true
1212
rand.workspace = true
1313
rivet-envoy-protocol.workspace = true
1414
rivet-util-serde.workspace = true
15+
rustls.workspace = true
1516
scc.workspace = true
1617
serde.workspace = true
1718
serde_bare.workspace = true

engine/sdks/rust/envoy-client/src/connection.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,12 @@ async fn single_connection(
8181
p
8282
};
8383

84+
// Initialize with a default CryptoProvider for rustls
85+
let provider = rustls::crypto::ring::default_provider();
86+
if provider.install_default().is_err() {
87+
tracing::debug!("crypto provider already installed in this process");
88+
}
89+
8490
let request = tungstenite::http::Request::builder()
8591
.uri(&url)
8692
.header("Sec-WebSocket-Protocol", protocols.join(", "))

0 commit comments

Comments
 (0)